-3

我有一个可以工作的 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.".
4

1 回答 1

0

请检查您的 foxpro 数据库 .. 我认为 foxpro 数据库afed中不存在表。这就是为什么在放置静态值而不是o.

于 2013-10-02T07:46:41.730 回答