对象'Refresh'的方法'IAdodc'失败是怎么回事?
Private Sub DataGrid2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 And Shift = 0 Then
PopupMenu popmenu.popmenu4
End If
End Sub
Private Sub Form_Load()
Dim strQuery As String
strQuery = "select * from Pay order by ID"
Adodc2.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=MIC;Data Source=."
Me.Adodc2.RecordSource = strQuery
If strQuery <> "" Then
Me.Adodc2.Refresh
End If
Set Me.DataGrid2.DataSource = Me.Adodc2.Recordset
Me.DataGrid2.Refresh
End Sub
[解决办法]
问题有可能出在你的
strQuery = "select * from Pay order by ID"
Adodc2.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=MIC;Data Source=."
Me.Adodc2.RecordSource = strQuery
If strQuery <> "" Then
这一块,因为我也遇到你这样的问题,因为Adodc2没有找到数据源,所以没有数据,就无法更新了。
[解决办法]
这类错误往往是控件与数据库连接有问题引起的
[解决办法]
建议尽量不要使用数据控件,手工控制数据连接,呵呵。