显示sql查询分析器消息栏”(5 行受影响)“这么显示?
text1.text = Rs.recordcount是返回查询语句查询出数据个数。我用的insert into 语句,我想显示sql server 查询分析器消息栏里”(5 行受影响)“这个信息,这个怎么在text1.text中显示啊
--------------------编程问答-------------------- 请把你的Insert Into语句完整的贴出来看看 --------------------编程问答--------------------
Dim Cnn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Cnn.ConnectionString = "Provider=SQLOLEDB;Data Source=john;UID=sa;PWD=123;initial catalog=aaa"
Cnn.Open
Rs.Open "insert into wdx select 1,2 union all select 2,2", Cnn, 3
。。。。。。。。
--------------------编程问答-------------------- 抱歉,你这个SQL语句我没看懂的说:“select 1,2 union all select 2,2”这是把啥查出来了?在你的查询分析器里能得到你想要的结果么? --------------------编程问答-------------------- 如果你的SQL语句没错,可以像下面这样得到会影响到的行数:
Dim Cnn As ADODB.Connection--------------------编程问答--------------------
Dim cmd As ADODB.Command
Dim lngAffected As Integer
Set Cnn = New ADODB.Connection
Cnn.ConnectionString = "Provider=SQLOLEDB;Data Source=john;UID=sa;PWD=123;initial catalog=aaa"
Cnn.Open
Set cmd = New ADODB.Command
' Set the connection to use for this command
cmd.ActiveConnection = Cnn
' Set the properties of the command
cmd.CommandType = adCmdText
cmd.CommandText = _
"insert into wdx select 1,2 union all select 2,2"
' And execute it
cmd.Execute lngAffected
Debug.Print lngAffected & " Records affected"
Set cmd = Nothing
Cnn.Close
Set Cnn = Nothing
up ls --------------------编程问答-------------------- 西西也开始搞数据库了?
select 1,2 union all select 2,2
这句也能执行,结果:
1 2
2 2
--------------------编程问答--------------------
--------------------编程问答--------------------
dim cn as connection
dim n as long
'......
cn.execute "insert into...",n
msgbox "所影响的行数:"& n
好办法....
补充:VB , 基础类