English 中文(简体)
无法使用OleDBAdapter插入一个表格
原标题:Unable to insert row to a table using OleDBAdapter
OleDbConnection _connection = new OleDbConnection();
        StringBuilder ConnectionString = new StringBuilder("");
        ConnectionString.Append(@"Provider=Microsoft.Jet.OLEDB.4.0;");
        ConnectionString.Append(@"Extended Properties=Paradox 5.x;");
        ConnectionString.Append(@"Data Source=C:ClientsRailWheelsets;");
        _connection.ConnectionString = ConnectionString.ToString(); 
        _connection.Open();
        OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM Vehicles;", _connection);
        DataSet dsRetrievedData = new DataSet();
        da.Fill(dsRetrievedData);   
        OleDbCommandBuilder builder = new OleDbCommandBuilder(da);
        da.InsertCommand = builder.GetInsertCommand();
        ////Insert new row
        DataRow rowNew = dsRetrievedData.Tables[0].NewRow();
        rowNew[dsRetrievedData.Tables[0].Columns[0].ColumnName] = "978";
        rowNew[dsRetrievedData.Tables[0].Columns[1].ColumnName] = "222";
        rowNew[dsRetrievedData.Tables[0].Columns[4].ColumnName] = "999";
        rowNew[dsRetrievedData.Tables[0].Columns[5].ColumnName] = "999";
        rowNew[dsRetrievedData.Tables[0].Columns[6].ColumnName] = "999";
        dsRetrievedData.Tables[0].Rows.Add(rowNew);
        dsRetrievedData.Tables[0].AcceptChanges();
        dsRetrievedData.AcceptChanges();
        int result = da.Update(dsRetrievedData);

thats the code i use. as you can see i have a paradox table. and some how result = 0 at end of it all. any ideas what is my mistake?

亲爱。

-=Noam=

问题回答

你们的加入是什么?

在拆除这两条线后,还试图拆除这条线。

dsRetrievedData.Tables[0].AcceptChanges();
dsRetrievedData.AcceptChanges();

您 对数据表的所有改动都被接受,因此没有变化的行文,因此没有更新数据。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签