Dim rs1 As ADODB.Recordset
Dim str1 As String
str1 = "SELECT * From QQ WHERE (myname ='" & myname & "')"
Set rs1 = New ADODB.Recordset
data1.qq1.Open
rs1.Open str1, data1.qq1
rs1!myname = Text1.Text
rs1!myid = Text2.Text
rs1!myip = Text3.Text
rs1!myport = Text4.Text
data1.qq1.Close错误提示:
对象或提供者不能执行所需的操作。提示是第5行出错
立等给分
Dim str1 As String
str1 = "SELECT * From QQ WHERE (myname ='" & myname & "')"
Set rs1 = New ADODB.Recordset
data1.qq1.Open
rs1.Open str1, data1.qq1
rs1!myname = Text1.Text
rs1!myid = Text2.Text
rs1!myip = Text3.Text
rs1!myport = Text4.Text
data1.qq1.Close错误提示:
对象或提供者不能执行所需的操作。提示是第5行出错
立等给分
工程--->引用--->Microsoft ActiveX Data Object 2.x(版本号)Option ExplicitDim WithEvents adoRS As Recordset
Dim db As Connection
'提数据事件
Set db = New Connection
db.CursorLocation = adUseClient
db.Open"Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & App.Path & "\db1.mdb;Jet OLEDB:Database Password=1234;"
' ##########################################
'打开密码是1234的Access2000数据库db1.mdb
'不需要密码,就把Jet OLEDB:Database Password=1234;这段去掉 Set adoRS = New Recordset
adoRS.Open "SELECT * FROM 表", db, adOpenStatic, adLockOptimistic
'赋值给 DataGrid 表
Set DataGrid1.DataSource = adoRS
'表刷新
DataGrid1.Refresh '如果要绑定TextBox(数组):
'Text1(0).DataField = 字段1
'Text1(1).DataField = 字段2
'.........
Dim oText As TextBox 'TextBox
For Each oText In Me.Text1
Set oText.DataSource = adoRS
Next
'添加事件和保存
adoRS.AddNew
'保存
adoRS![字段a] = text1.Text
adoRS![字段b] = text2.Text
adoRS.UpdateBatch adAffectAll'删除
adoRS.Delete
'重新赋值给表
adoRS.Requery
Set DataGrid1.DataSource = adoRS
DataGrid1.Refresh '其他相关操作:
'上一条
If Not adoRS.BOF Then adoRS.MovePrevious
If adoRS.BOF And adoRS.RecordCount > 0 Then
'已到最后返回
adoRS.MoveFirst
End If
'下一条
If Not adoRS.EOF Then adoRS.MoveNext '下一条
If adoRS.EOF And adoRS.RecordCount > 0 Then
'已到最后返回
adoRS.MoveLast
End If
'第一条
If Not adoRS.BOF Then adoRS.MoveFirst
'最末
If Not adoRS.EOF Then adoRS.MoveLast
:( 郁闷ing