VB程序员博客
Private Sub Form_Load()
On Error GoTo err
With CommonDialog1
.FileName = "*.xls "
.Filter = "(Excel)*.xls|*.xls "
.CancelError = True
.ShowOpen
End With
excelPath = CommonDialog1.FileName
Dim cn As New ADODB.Connection
Dim rs As New Recordset
cn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=sales "
cn.Open
cn.Execute "select * into invest1 from OpenRowSet( 'microsoft.jet.oledb.4.0 ', 'Excel 8.0;HDR=Yes;database=CommonDialog1.FileName; ', 'select * from [Sheet1$] ') "
'此处如果使用具体的路径则导入成功,若不是则报错“OLE DB提供程序,想请教!‘ 'microsoft.jet.oledb.4.0 '’报错”
cn.Close
Set cn = Nothing
Adodc1.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=sales "
Exit Sub
err:
MsgBox err.Description
End Sub
出现这样的错误
[OLE/DB provider returned message:找不到可安装的 ISAM.]
都是很好的建议! 值得学习