Reputation: 77
I 'm running a FoxPro Command in Visual Studio 2017. I want To execute the second command text pre-requisite To the first, And so on. Any help?
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:\temp\products"
cmd.ExecuteNonQuery()
cmd.CommandText = "INDEX ON productid TAG productid"
cmd.ExecuteNonQueryAsync()
cmd.CommandText = "INDEX ON prodname TAG prodname"
cmd.ExecuteNonQueryAsync()
cn.Close()
End Using
Upvotes: 0
Views: 395
Reputation: 4288
You need to use the Visual FoxPro ExecScript() command and don't execute the the commands asynchronously.
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:\temp\products 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
Upvotes: 1