温馨提示:本文翻译自stackoverflow.com,查看原文请点击:indexing - FoxPro Command to VB.NET
indexing vb.net command visual-foxpro foxpro

indexing - FoxPro命令到VB.NET

发布于 2020-04-04 10:31:59

我在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:\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

查看更多

提问者
404notfound
被浏览
103
Alan B 2020-02-27 22:00

您需要使用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:\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