我在Visual Studio 2017中运行FoxPro命令。 我想执行第二个命令文本的先决条件 到第一个,依此类推。有什么帮助吗?
Dim a = "Provider=VFPOLEDB.1;Data Source=C:temp;Extended Properties=dBase IV"
Using cn As New OleDbConnection(a)
cn.Open()
Dim cmd As New OleDbCommand
cmd.Connection = cn
cmd.CommandText = "use C:tempproducts"
cmd.ExecuteNonQuery()
cmd.CommandText = "INDEX ON productid TAG productid"
cmd.ExecuteNonQueryAsync()
cmd.CommandText = "INDEX ON prodname TAG prodname"
cmd.ExecuteNonQueryAsync()
cn.Close()
End Using
您需要使用 Visual FoxPro ExecScript(( 命令,并且不要异步执行这些命令。
Dim a = "Provider=VFPOLEDB.1;Data Source=C:temp;Extended Properties=dBase IV"
Using cn As New OleDbConnection(a)
cn.Open()
Dim cmd As New OleDbCommand
cmd.Connection = cn
cmd.CommandText = "execscript(['use C:tempproducts excl'])"
cmd.ExecuteNonQuery()
cmd.CommandText = "execscript(['INDEX ON productid TAG productid'])"
cmd.ExecuteNonQuery()
cmd.CommandText = "execscript(['INDEX ON prodname TAG prodname'])"
cmd.ExecuteNonQuery()
cn.Close()
End Using