dim cnn as new adodb.connection
dim af as long
cnn.open conStr
cnn.execute "select * from xtable",af,adCmdTextxtable中有数据,可是af的值还是-1
af的值不是运行语句后影响的行数吗?不解,郁闷,帮忙看看,谢谢!!
dim af as long
cnn.open conStr
cnn.execute "select * from xtable",af,adCmdTextxtable中有数据,可是af的值还是-1
af的值不是运行语句后影响的行数吗?不解,郁闷,帮忙看看,谢谢!!
dim af as long
cnn.CursorLocation = adUseClient '<---------------------设置客户端游标
cnn.open conStr
cnn.execute "select * from xtable",af,adCmdText
cnn.CursorLocation = adUseClientadUseClient 使用由本地游标库提供的客户端游标。本地游标引擎通常允许使用的许多功能可能是驱动程序提供的游标无法使用的,因此使用该设置对于那些将要启用的功能是有好处的。adUseClientBatch 与 adUseClient 同义,也支持向后兼容性。
adUseServer 默认值。使用数据提供者或驱动程序提供的游标。这些游标有时非常灵活,对于其他用户对数据源所作的更改具有额外的敏感性。但是,Microsoft Client Cursor Provider(如已断开关联的记录集)的某些功能无法由服务器端游标模拟,通过该设置将无法使用这些功能。
Private Sub Command1_Click()
Dim af As Long
af = 0
cnn.CursorLocation = adUseClient
cnn.Open "Provider=SQLOLEDB.1;Password=;Persist Security Info=True; "_
& "User ID=sa;Initial Catalog=Bingo;Data Source=cosmos\mydb"
cnn.Execute "select * from wwUser", af, adCmdText
Text1.Text = af
End Sub这样做还是得不到,af的值还是不对啊
dim rst as new adodb.recordset'<------------------------------定义记录集对象
Private Sub Command1_Click()
Dim af As Long
af = 0
cnn.CursorLocation = adUseClient
cnn.Open "Provider=SQLOLEDB.1;Password=;Persist Security Info=True; "_
& "User ID=sa;Initial Catalog=Bingo;Data Source=cosmos\mydb"
set rst=cnn.Execute("select * from wwUser", af, adCmdText)'<------------给rst赋值
Text1.Text = af'得到影响的行数
End Sub
Public CurConn As New ADODB.Connection '数据库连接
Sub Main()
'连接字符串(本例子是oracle,对别的一样)
strConn = "Provider=OraOLEDB.Oracle.1;Persist Security Info=True;" & _
"Data Source=" & strDataSource & ";" & _
"User ID=" & LogID & ";" & _
"Password=" & LogPWD
With CurConn
.CommandTimeout = 3
.ConnectionTimeout = 3
.ConnectionString = strConn
.Open
.CursorLocation = adUseClient
End With
frm_main.Show
Exit Sub
errConn:
MsgBox Err.Description, vbCritical + vbOKOnly, "错误"
end Sub
'读记录*******************************
Private Sub CmdQuery_Click()
Dim sQuery As String
Dim QueryRS As New ADODB.Recordset
sQuery = "select * from 表名"
On Error GoTo ErrQuery
Set QueryRS = CurConn.Execute(sQuery)
If Not (QueryRS.BOF And QueryRS.EOF) Then
Do While Not QueryRS.EOF
'此处往表格里写
QueryRS.MoveNext
Loop
Else
MsgBox "没有记录!", vbExclamation, "提示信息"
End If
QueryRS.Close
Set QueryRS = Nothing
Exit Sub
ErrQuery:
MsgBox Err.Description, vbCritical, "提示信息"
End Sub
ado的记录集里记录的数量本来就是个近似值
你可以看看msdn里面写的很清楚