求助 VB语句rstemp.Open strsql, conn, 1, 1执行过不去
Private Sub command1_Click ()Dim strconn As String ' 定义连接字符串
' 初始化记录集及连接
Set rstemp = CreateObject (" ADODB.Recordset")
Set conn = CreateObject (" adodb.connection")
' 打开连接,并加参数
Strconn=" Provider=SQLOLEDB.1;Persist Security Info=
False;User ID =sa;password =333666;Initial Catalog =data;Data
Source= (local)"
conn.Open strconn
' 选取Excel 数据文件,文件路径及名称记录在Com
'monDialog1.FileName 中
'CommonDialog1.ShowOpen
' 写SQL 语句,数据写入SQL Server 中
strsql = " select * into tablename from OpenRowSet
( 'microsoft.jet.oledb.4.0','Excel 8.0;HDR =Yes;database = E:\TEST.xls;','select * from [sheet1$] ')
where "
rstemp.Open strsql, conn, 1, 1
' 提示
MsgBox " 数据导入成功!" , vbExclamation +
vbOKOnly
' 关闭数据库连接及记录集,释放资源
conn.Close
Set conn = Nothing
rstemp.Close
Set rstemp = Nothing
End Sub
执行到红色的就过不去了,在别人电脑上可以运行,自己的VB 与SQL都重装了也不行,好几种方式修改都不行,希望大家帮帮忙。蓝色语句在SQL查询器中查询显示无错误!