text1.text = Rs.recordcount是返回查询语句查询出数据个数。
我用的insert into 语句,我想显示sql server 查询分析器消息栏里”(5 行受影响)“这个信息,这个怎么在text1.text中显示啊
我用的insert into 语句,我想显示sql server 查询分析器消息栏里”(5 行受影响)“这个信息,这个怎么在text1.text中显示啊
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
。。
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
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