this is my code
//Probando insercion
        OleDbConnection conexionFoxPro = new OleDbConnection();
        string rutaFoxPro = @"C:\Users\BigMander\Documents\Proyectos de Visual FoxPro\prueba.dbc";
        conexionFoxPro.ConnectionString = String.Format("Provider=VFPOLEDB.1;Data Source={0};Exclusive=Yes;", rutaFoxPro);
        bool sePudoEjecutarTodo = true;
        try
        {
            conexionFoxPro.Open();
            OleDbCommand comandoFoxPro = new OleDbCommand();
            comandoFoxPro.CommandText =
                @"INSERT INTO test ([nombre], [telefono], [id]) VALUES (?, ?, ?)";
            开发者_StackOverflow社区comandoFoxPro.Parameters.Add("nombre", OleDbType.Char).Value = "bigmander";
            comandoFoxPro.Parameters.Add("telefono", OleDbType.Char).Value = "some number";
            comandoFoxPro.Parameters.Add("id", OleDbType.Integer).Value = 5;
            comandoFoxPro.Connection = conexionFoxPro;
            sePudoEjecutarTodo &= (comandoFoxPro.ExecuteNonQuery() > 0);
            comandoFoxPro.CommandText =
                @"SELECT nombre, telefono FROM test";
            OleDbDataReader reader = comandoFoxPro.ExecuteReader();
            while (reader.Read())
            {
                Console.WriteLine("{0}: {1}", reader.GetName(0), reader["nombre"]);
                Console.WriteLine("{0}: {1}", reader.GetName(1), reader["telefono"]);
            }
            reader.Close();
            reader.Dispose();
            comandoFoxPro.CommandText =
                "DELETE FROM test WHERE id = 5";
            sePudoEjecutarTodo &= (comandoFoxPro.ExecuteNonQuery() > 0);
            comandoFoxPro.CommandText =
                "SET EXCLUSIVE ON; PACK test";
            sePudoEjecutarTodo &= (comandoFoxPro.ExecuteNonQuery() > 0);
        }
        catch(OleDbException oleDbE)
        {
            sePudoEjecutarTodo = false;
            Console.WriteLine(oleDbE.Message);
        }
        finally
        {
            if (sePudoEjecutarTodo)
                Console.WriteLine("Congratulaciones si se armo todo");
            else
                Console.WriteLine("Pelas");
            conexionFoxPro.Close();
            Console.ReadKey();
        }
i have a database in foxpro 9 with one testing table named test, and i tested with normal sql sentences, and everything is going fine except for the pack statement whom delete data physically from the database, i found and example that shows me how to do it but its with other kinda drive (adodb), but even if i can do it with that code i want to know how could this stuff works in oledb.
    static void Main(string[] args)
    {
    Console.WriteLine("Starting program execution...");
    string connectionString = @"Provider=VFPOLEDB.1;Data Source=h:\dave\"; 
    using (OleDbConnection connection = new OleDbConnection(connectionString)) 
    { 
        using (OleDbCommand scriptCommand = connection.CreateCommand()) 
        { 
            connection.Open();
            string vfpScript = @"SET EXCLUSIVE ON
                                DELETE FROM test WHERE id = 5
                                PACK"; 
            scriptCommand.CommandType = CommandType.StoredProcedure; 
            scriptCommand.CommandText = "ExecScript"; 
            scriptCommand.Parameters.Add("myScript", OleDbType.Char).Value = vfpScript; 
            scriptCommand.ExecuteNonQuery(); 
        } 
    } 
    Console.WriteLine("End program execution..."); 
    Console.WriteLine("Press any key to continue"); 
    Console.ReadLine(); 
    }
I've never noticed VFP to use ; to differentiate BETWEEN statements. VFP uses ; to identify statement continues on next line (exact opposite of C# and other languages).
So, I would change your command text at the end to the following
comandoFoxPro.CommandText = "USE TEST EXCLUSIVE \r\n"
                            "PACK \r\n"
                            "USE \r\n";
sePudoEjecutarTodo &= (comandoFoxPro.ExecuteNonQuery() > 0);  
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论