Insert multiple rows in dbf file with DataAdapter RRS feed

  • Question

  • I want to insert multiple rows in dbf file with single operation. Here is code, I have written.

                OleDbConnection oConn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\foxtmp\\fencepip.DBF;Extended Properties=dBASE IV;User ID=Admin;Password=;");
                OleDbDataAdapter da = new OleDbDataAdapter();
                DataTable dt = new DataTable();
                oConn.ConnectionString = "Provider=VFPOLEDB.1;Data Source=c:\\foxtmp\\fencepip.DBF;Exclusive=false;Nulls=false";
                OleDbCommandBuilder cb = new OleDbCommandBuilder(da);
                da.SelectCommand = new OleDbCommand("select * from fencepip", oConn);

                for (int i = 0; i < 3000; i++)
                    DataRow row = dt.NewRow();
                    row[0] = i;
                    row[1] = i;
                    row[2] = i;
                    row[3] = false;
                da.InsertCommand = cb.GetInsertCommand();

    I am getting OleDbException at da.Update() statement. with error "One or more errors occurred during processing of command.".

    Please provide soluton for this, will also appreciate if you suggest some other way to do batch insertion in dbf  file. Thanks in advance.
    Wednesday, November 18, 2009 3:49 PM


  • I found solution , removed dbf file name from connection string and it started working. Thanks!!
    • Marked as answer by kmp3006 Wednesday, November 18, 2009 5:31 PM
    Wednesday, November 18, 2009 5:31 PM