我有一个可以工作的 select into 语句,但是当我把它放在循环中时,它失败了。有谁知道为什么会这样?
谢谢!
这是代码:
For o = 0 To x
tables = ListBox1.Items.Item(o).ToString
sqlstr = "SELECT * into dbo." & tables & " FROM OPENROWSET('MSDASQL', 'Driver=Microsoft Visual FoxPro Driver; SourceDB=C:\exports\DBF; SourceType = DBF ', 'SELECT * FROM " & tables & "')"
mycmd = New SqlCommand
sqlcon = New SqlConnection(con)
mycmd.CommandText = sqlstr
sqlcon.Open()
mycmd.Connection = sqlcon
mycmd.ExecuteNonQuery()
sqlcon.Close()
Next
当我尝试执行此操作时,它给了我以下错误
Cannot execute the query "SELECT * FROM AFED" against OLE DB provider "MSDASQL"
for linked server "(null)". OLE DB provider "MSDASQL"
for linked server "(null)" returned message
"[Microsoft][ODBC Visual FoxPro Driver]File 'afed.dbf' does not exist.".