views:

754

answers:

1

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

A: 

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.

Dani
The wizzard has already created lot of code, and I guess it has the connection string, etc. because when Mainform shows, the DataGridView loads the data from the mdb table. Will I need also need to create that connection object, dataadapter, etc.?Where is that wizzard you point, located?Thanks
Enrique
Project source code is herehttp://www.mediafire.com/?zwotmgwvzii
Enrique
The data adapters it probably already exists if you got the data. I will checkout your project and see later today.
Dani
ok, got your sln. do you need to append and delete rows to the grid ?
Dani