Failure creating file
请大家帮忙看看,为何会出现 error:Failure creating file 但有些电脑又不会出现这样的错误。
程序代码:
Dim Conn As New ADODB.Connection Dim Cnn As New ADODB.Connection Dim Rst As New ADODB.Recordset Dim Rs As New ADODB.Recordset Set Conn = New ADODB.Connection Set Cnn = New ADODB.Connection Dim StrSql As String CommonDialog1.ShowOpen strFileName = CommonDialog1.FileName CommonDialog1.Filter = "Excel File|*.xls;*xlsx;*xlsm|" If CommonDialog1.FileName = "" Then Exit Sub Set Cnn = CreateObject("adodb.connection") Cnn.Open "Provider=Microsoft.Ace.OLEDB.12.0;Extended Properties=Excel 12.0;Data Source=" & strFileName Sql = "select * from [Sheet1$A:C]" Rs.Open Sql, Cnn, adOpenStatic With Conn .CursorLocation = adUseClient .CommandTimeout = 300 End With Conn.Open _ "Provider=SQLOLEDB.1;" & _ "Persist Security Info=True;" & _ "User ID=TestAccount;" & _ "Password=@123456;" & _ "Data Source=sql05;" & _ "Initial Catalog=TEST" For i = 1 To Rs.RecordCount StrSql = "" If IsNull(Rs(2)) = True Then GoTo NextItem StrSql = "INSERT INTO [PrepPartList] (RawPart,PrePart,Demand) VALUES ('" & Rs(0) & "','" & Rs(1) & "','" & Rs(2) & "')" Conn.Execute StrSql NextItem: Rs.MoveNext Next
[此贴子已经被作者于2017-4-11 17:18编辑过]