在vb中如何只用datagrid控件连接数据库并显示出来 要完整的代码 5
下面是我写的,表里有内容为什么说读取数据失败PubliccnnAsadodb.ConnectionPublicrstAsadodb.RecordsetPublicSubs...
下面是我写的,表里有内容为什么说读取数据失败
Public cnn As adodb.Connection
Public rst As adodb.Recordset
Public Sub setdb()
Set cnn = New adodb.Connection
cnn.Provider = "Microsoft.Jet.OLEDB.4.O"
cnn.ConnectionString = "Data Source=" & App.Path & "\personal.mdb;"
cnn.CursorLocation = adUseClient
cnn.Open
End Sub
Private Sub Form_Load()
On Error Resume Next
Dim Strsql As String
setdb
Set DataGrid1.DataSource = Nothing
Strsql = "select * from 备忘录 order by 编号"
Set rst = cnn.Execute(Strsql)
If Err Then
MsgBox "读取数据失败"
Exit Sub
End If
If rst.EOF Then
Set DataGrid1.DataSource = Nothing
Else
Set DataGrid1.DataSource = rst
End If
End Sub 展开
Public cnn As adodb.Connection
Public rst As adodb.Recordset
Public Sub setdb()
Set cnn = New adodb.Connection
cnn.Provider = "Microsoft.Jet.OLEDB.4.O"
cnn.ConnectionString = "Data Source=" & App.Path & "\personal.mdb;"
cnn.CursorLocation = adUseClient
cnn.Open
End Sub
Private Sub Form_Load()
On Error Resume Next
Dim Strsql As String
setdb
Set DataGrid1.DataSource = Nothing
Strsql = "select * from 备忘录 order by 编号"
Set rst = cnn.Execute(Strsql)
If Err Then
MsgBox "读取数据失败"
Exit Sub
End If
If rst.EOF Then
Set DataGrid1.DataSource = Nothing
Else
Set DataGrid1.DataSource = rst
End If
End Sub 展开
展开全部
Public cnn As adodb.Connection
Public rst As adodb.Recordset
Public Sub setdb()
Set cnn = New adodb.Connection
cnn.Provider = "Microsoft.Jet.OLEDB.4.O"
cnn.ConnectionString = "Data Source=" & App.Path & "\personal.mdb;"
cnn.CursorLocation = adUseClient
cnn.Open
End Sub
Private Sub Form_Load()
On Error Resume Next
Dim Strsql As String
setdb
Set DataGrid1.DataSource = Nothing
Strsql = "select * from 备忘录 order by 编号"
Set rst = cnn.Execute(Strsql)
If Err Then
MsgBox "读取数据失败"
Exit Sub
End If
If rst.EOF Then
Set DataGrid1.DataSource = Nothing
Else
Set DataGrid1.DataSource = rst
End If
End Sub
我帮你整理了以下,这样好看一些
网易云信
2023-12-06 广告
2023-12-06 广告
网易云信提供一站式的 1 对 1 UIKit 组件库,可以更快地搭建 1 对 1 社交平台,能够快速实现音视频呼叫、音视频通话、1对1消息发送、美颜和礼物功能,直接可以复用我们的组件源码就可以了。优势:1、全套1对1 UI组件,接入更快;2...
点击进入详情页
本回答由网易云信提供
展开全部
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |