首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

vb 连接Access出现有关问题,请指点

2012-01-20 
vb 连接Access出现问题,请指点连接数据库,提示找不到可安装的ISAM,我的代码问题出在那啊PrivateSubCommand

vb 连接Access出现问题,请指点
连接数据库,提示找不到可安装的ISAM,我的代码问题出在那啊
Private   Sub   Command1_click()
Dim   cnn   As   New   ADODB.Connection
Dim   rs1   As   New   ADODB.Recordset
Dim   varSource   As   String
varSource   =   "select   *   from   TireData   where   TireManufacturer=   Text1.text   and   DataNo=1 "
cnn.ConnectionString   =   "Provider=Microsoft.Jet.OLEDB.4.0;Persist       Security       Info=False;Data       Source= "   &   App.Path   &   "\yanshi.mdb "
cnn.Open
Set   rs1.ActiveConnection   =   cnn
rs1.LockType   =   adLockOptimistic
rs1.CursorType   =   adOpenKeyset
rs1.Open   varSource
Set   DataGrid1.DataSource   =   cnn
            DataGrid1.Visible   =   True
rs1.Close
cnn.Close
End   Sub


[解决办法]
试试以下代码,如有问题,请新建VB的数据工程,在数据工程的窗体添加Command1控件和DataGrid1控件,并执行以下代码.
Private Sub Command1_Click()
Dim cnn As New ADODB.Connection
Dim rs1 As New ADODB.Recordset
Dim varSource As String
varSource = "select * from TireData "
cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "\yanshi.mdb "
cnn.Open
rs1.CursorLocation = adUseClient
rs1.Open varSource, cnn, 3, 3
Set DataGrid1.DataSource = rs1
DataGrid1.Visible = True
End Sub

热点排行