找不到可安装的ISAM 急需解决!!
Private Sub Command1_Click()Text1.Text = App.Path & "\taxi.xls"
Text2.Text = App.Path & "\taxi.mdb"
Text3.Text = "sheet1"
Text4.Text = "sheet1"
Dim mypath As String
mypath = VB.App.Path & "\database\taxi.mdb"
Adodc1.ConnectionString = "provider = microsoft.jet.oledb.4.0;data sourse = " & mypath & ";persist security info = false"
Dim db As Database
Dim sheet As String, excelpath As String, AccessPath As String, AccessTable As String
AccessPath = Text2.Text
excelpath = Text1.Text
AccessTable = Text4.Text
sheet = Text3.Text
Set db = OpenDatabase(excelpath, True, False, "Excel 5.0")
SQL = (" insert into fanzui SELECT *FROM [Excel 5.0;HDR=YES;IMEX=2;DATABASE=f:\taxi.xls].[sheet1$];")
db.Execute (SQL)
Adodc1.RecordSource = "sheet1"
Adodc.Refresh
DBGrid1.Refresh
End Sub
运行时提示找不到可安装的ISAM,我用的是VB6.0 access2003,哪位高手帮帮忙?? --------------------编程问答-------------------- 改用ADO控件吧 --------------------编程问答-------------------- 我用的就是ado啊.... --------------------编程问答-------------------- Dim db As Database
改成:
dim db as new adodb.recordset
试试 --------------------编程问答-------------------- 没有正确安装Microsoft Data Access Components.
找到vb6安装程序中的MDAC_TYP.EXE并安装,记住配置选择全部,
安装完后应该没问题了. --------------------编程问答-------------------- 改过之后,又提示Set db = OpenDatabase(excelpath, True, False, "Excel 5.0") 这句话:类型不匹配,怎么办呢?
--------------------编程问答-------------------- 代码写错的原因 :data sourse 应为 data source --------------------编程问答-------------------- 把Adodc1.ConnectionString的后面改成adodc控件属性ConnectionString里自动生成的代码
我的是这样解决的,不知道你的是不是 --------------------编程问答-------------------- 给你几个函数,绝对能用
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'函数功能:连接指定的数据库
'参数说明:cnnP:数据库连接对象;
' :adoP:数据集存储对象;
' :strPath:数据库路径;
' :strPassword:数据库密码;
'返回说明:True:连接成功 False:连接失败
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Public Function funConnectDataBase(cnnP As ADODB.Connection, adoP As ADODB.Recordset, ByVal strPath As _
String, ByVal strPassword As String) As Boolean
On Error GoTo errFunction
Set cnnP = New ADODB.Connection
Set adoP = New ADODB.Recordset
cnnP.Provider = "Microsoft.Jet.OLEDB.4.0"
cnnP.Open "Data Source = " & strPath & ";jet oledb:database password=" & strPassword
funConnectDataBase = True
Exit Function
errFunction:
funConnectDataBase = False
End Function
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'函数功能:关闭数据库连接对象和数据文件的关联
'参数说明:cnnP:数据库连接对象;
' :adoP:数据库存储对象;
'返回说明:True:关闭连接成功 False:关闭连接失败
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Public Function funCloseDataBase(cnnP As ADODB.Connection, adoP As ADODB.Recordset) As Boolean
On Error GoTo errFunction
Set adoP = Nothing
Set cnnP = Nothing
funCloseDataBase = True
Exit Function
errFunction:
funCloseDataBase = False
End Function
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'过程功能:对指定的对象执行指定的SQL语句
'参数说明:cnnP:ADO连接对象
' :adoP:ADO记录集对象
' :strSql:SQL语句
' :bolQueryRecord:是否是查询记录集
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Public Sub subExcuteSQL(cnnP As ADODB.Connection, adoP As ADODB.Recordset, strSql As String, bolQueryRecord _
As Boolean)
If bolQueryRecord Then '如果是查询记录集
adoP.Open strSql, cnnP, adOpenStatic, adLockBatchOptimistic
Else
cnnP.Execute strSql
End If
End Sub --------------------编程问答-------------------- 请安装vbsp4和sp5就行了,因为vb6最原始的版本是不支持access2000及以上版本的。
补充:VB , 数据库(包含打印,安装,报表)