开发者

Visual C# 2008. CRUD Example using Dataset, DataRow with an Access Mdb

开发者_JAVA技巧I'm using Visual Studio C# 2008

I've created (visually) a dataset that points to a mdb file (Access 2007)

This DataSet is called "EstacionarDataSet"

EstacionarDataSet ed = new EstacionarDataSet();
DataRow newRow = ed.Tables[0].NewRow();
newRow["patente"] = tb_Patente.Text;
newRow["numerobox"] = tb_Box.Text;
newRow["fechahora_ingreso"] = DateTime.Now;
ed.Tables[0].Rows.Add(newRow);
  • This code is executed in a Form2 (not mainform), where I'm trying to insert a new record into the only table mdb file has (this code doesn't work, but doesn't give any exception).

  • The mainform contains a System.Windows.Forms.DataGridView component, attached to this mdb file, which works fine, it shows the records correctly, etc. (PS: I added some sample records using Access)

  • I'm needing some code samples for adding a new row, updating, and deleting... Thanks


You need to understand how DataAdapter works:

read this article

DataAdapter

or many other in the web.

Then All you need is a connection object to the MDB, A configured dataadapter with select insert and update commands (can be easily done with the wizard).

and fill a table or dataset with the data, binding it to the gridview.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜