VB.NET的FoxPro命令

问题描述 投票:0回答:1

我正在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
vb.net indexing command visual-foxpro foxpro
1个回答
0
投票

您需要使用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'])"
    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
© www.soinside.com 2019 - 2024. All rights reserved.