vb报语法错误
PrivateSubCommand1_Click()DimstrSQLAsStringCommonDialog1.Filter="电子表格文件(.xls)|*.xls"C...
Private Sub Command1_Click()
Dim strSQL As String
CommonDialog1.Filter = "电子表格文件(.xls)|*.xls"
CommonDialog1.DialogTitle = "请选择要导入的文件"
CommonDialog1.ShowOpen
Dim Sqlcn As New ADODB.Connection
'SQL数据库连接
Sqlcn.CursorLocation = adUseClient
Sqlcn.ConnectionString = " Provider=SQLOLEDB.1;Persist Security Info=False;User ID =sa;password =123qwe;Initial Catalog =DATA;DataSource= (local)"
Sqlcn.Open
'定义连接excel字符串
strSQL = "INSERT INTO userlist (id,name,pass,quan) SELECT (id,name,pass,quan) FROM OpenRowSet('microsoft.jet.oledb.4.0','Excel 8.0;HDR=Yes;database=" & CommonDialog1.FileName & " ;','select * from [Sheet1$] ')"
Sqlcn.Execute strSQL, , adExecuteNoRecords---这号报错
Sqlcn.Close
Set cn = Nothing
MsgBox "导入成功", vbExclamation + vbOKOnly
Exit Sub
End Sub
网上找的代码 运行说 Sqlcn.Execute strSQL, , adExecuteNoRecords有语法错误 展开
Dim strSQL As String
CommonDialog1.Filter = "电子表格文件(.xls)|*.xls"
CommonDialog1.DialogTitle = "请选择要导入的文件"
CommonDialog1.ShowOpen
Dim Sqlcn As New ADODB.Connection
'SQL数据库连接
Sqlcn.CursorLocation = adUseClient
Sqlcn.ConnectionString = " Provider=SQLOLEDB.1;Persist Security Info=False;User ID =sa;password =123qwe;Initial Catalog =DATA;DataSource= (local)"
Sqlcn.Open
'定义连接excel字符串
strSQL = "INSERT INTO userlist (id,name,pass,quan) SELECT (id,name,pass,quan) FROM OpenRowSet('microsoft.jet.oledb.4.0','Excel 8.0;HDR=Yes;database=" & CommonDialog1.FileName & " ;','select * from [Sheet1$] ')"
Sqlcn.Execute strSQL, , adExecuteNoRecords---这号报错
Sqlcn.Close
Set cn = Nothing
MsgBox "导入成功", vbExclamation + vbOKOnly
Exit Sub
End Sub
网上找的代码 运行说 Sqlcn.Execute strSQL, , adExecuteNoRecords有语法错误 展开
2个回答
金山毒霸
2024-10-31 广告
2024-10-31 广告
大部分系统错误,是因为某些DLL文件丢失造成的,比如未安装DirectX9或DirectX 9.0组件已损坏、缺少Visual C ++库、未安装.net库。解决方法如下:一、 手动解决方法1、先确定电脑操作系统是多少位的,现在的电脑一般都...
点击进入详情页
本回答由金山毒霸提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询