在VB数据库编程中,如果实现ADO 与DATAGRID控件的绑定?
我用下面的代码不行,请高手赐教,感谢ing!!!!!DimmyconAsNewADODB.ConnectionDimmyrsAsNewADODB.RecordsetPri...
我用下面的代码不行,请高手赐教,感谢ing!!!!!
Dim mycon As New ADODB.Connection
Dim myrs As New ADODB.Recordset
Private Sub Form_Load()
mycon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb;Persist Security Info=False"
mycon.Open
myrs.Open "select * from 职工基本信息", mycon, 3, 3
Set DataGrid1.DataSource = myrs
DataGrid1.Refresh
End Sub 展开
Dim mycon As New ADODB.Connection
Dim myrs As New ADODB.Recordset
Private Sub Form_Load()
mycon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb;Persist Security Info=False"
mycon.Open
myrs.Open "select * from 职工基本信息", mycon, 3, 3
Set DataGrid1.DataSource = myrs
DataGrid1.Refresh
End Sub 展开
3个回答
展开全部
mycon.CursorLocation = adUseClient
'使游标在客户端.否则adodb无法与DataGrid绑定
'出现 "行集合不能作为标标签" 错误
mycon.open
'这样一来就无法修改其中的数据了.
'建议用ADODC控件来与DataGrid绑定
Private Sub Form_Load()
mycon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb;Persist Security Info=False"
'##########################################################
mycon.CursorLocation = adUseClient
'##########################################################
mycon.Open
myrs.Open "select * from 职工基本信息", mycon, 3, 3
Set DataGrid1.DataSource = myrs
DataGrid1.Refresh
End Sub
'希望对你有所帮助
'使游标在客户端.否则adodb无法与DataGrid绑定
'出现 "行集合不能作为标标签" 错误
mycon.open
'这样一来就无法修改其中的数据了.
'建议用ADODC控件来与DataGrid绑定
Private Sub Form_Load()
mycon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb;Persist Security Info=False"
'##########################################################
mycon.CursorLocation = adUseClient
'##########################################################
mycon.Open
myrs.Open "select * from 职工基本信息", mycon, 3, 3
Set DataGrid1.DataSource = myrs
DataGrid1.Refresh
End Sub
'希望对你有所帮助
展开全部
1.看看自己是否已引用ado控件
2.以下定义最好改掉
Dim mycon As New ADODB.Connection
Dim myrs As New ADODB.Recordset
最好为
Dim mycon As ADODB.Connection
Dim myrs As ADODB.Recordset
Private Sub Form_Load()
set mycon = New ADODB.Connection
set myrs = New ADODB.Recordset
.........
3.二楼的是对滴~赶紧把分给人家~~
2.以下定义最好改掉
Dim mycon As New ADODB.Connection
Dim myrs As New ADODB.Recordset
最好为
Dim mycon As ADODB.Connection
Dim myrs As ADODB.Recordset
Private Sub Form_Load()
set mycon = New ADODB.Connection
set myrs = New ADODB.Recordset
.........
3.二楼的是对滴~赶紧把分给人家~~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
db="db1.mdb"
mycon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)"
这样试试
mycon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)"
这样试试
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询