S
sherifffruitfly
Hi all,
I've got a form with a datagrid defined & presented to the user at
runtime (code at the bottom.) With this, the user can happily enter
all the data she likes. After a row of data is entered in the
datagrid, and the datagrid is about to start a new row for the user,
I'd like an UpdateDatabase(DataRow rowJustEntered) to be called.
I suppose some kind of define-and-subscribe-to-some-event has to take
place, but that's precisely the sort of thing I don't understand so
well.
How can I do this? I'm imagining the database update routine to be
centered around an InsertCommand.ExecuteNonQuery() call.
Thanks for any help,
cdj
==========================
//manualForm is a Form with a DataGrid on it,
//and has already been instantiated.
DataSet manualDataSet = new DataSet();
manualDataSet.Tables.Add("table");
manualForm.dataGrid.SetDataBinding(manualDataSet, "table");
manualForm.Width = 300;
manualForm.StartPosition = FormStartPosition.CenterScreen;
DataTable theTable = manualDataSet.Tables["table"];
DataColumn colIndex = new DataColumn("index",
System.Type.GetType("System.Int32"));
DataColumn colDate = new DataColumn("date",
System.Type.GetType("System.DateTime"));
DataColumn colData = new DataColumn("data",
System.Type.GetType("System.Double"));
theTable.Columns.Add(colIndex);
theTable.Columns.Add(colDate);
theTable.Columns.Add(colData);
colIndex.AllowDBNull = false;
colDate.AllowDBNull = false;
colData.AllowDBNull = false;
DataColumn[] keyCols = {colIndex, colDate};
theTable.PrimaryKey = keyCols;
manualForm.dataGrid.ColumnHeadersVisible = true;
manualForm.Show();
I've got a form with a datagrid defined & presented to the user at
runtime (code at the bottom.) With this, the user can happily enter
all the data she likes. After a row of data is entered in the
datagrid, and the datagrid is about to start a new row for the user,
I'd like an UpdateDatabase(DataRow rowJustEntered) to be called.
I suppose some kind of define-and-subscribe-to-some-event has to take
place, but that's precisely the sort of thing I don't understand so
well.
How can I do this? I'm imagining the database update routine to be
centered around an InsertCommand.ExecuteNonQuery() call.
Thanks for any help,
cdj
==========================
//manualForm is a Form with a DataGrid on it,
//and has already been instantiated.
DataSet manualDataSet = new DataSet();
manualDataSet.Tables.Add("table");
manualForm.dataGrid.SetDataBinding(manualDataSet, "table");
manualForm.Width = 300;
manualForm.StartPosition = FormStartPosition.CenterScreen;
DataTable theTable = manualDataSet.Tables["table"];
DataColumn colIndex = new DataColumn("index",
System.Type.GetType("System.Int32"));
DataColumn colDate = new DataColumn("date",
System.Type.GetType("System.DateTime"));
DataColumn colData = new DataColumn("data",
System.Type.GetType("System.Double"));
theTable.Columns.Add(colIndex);
theTable.Columns.Add(colDate);
theTable.Columns.Add(colData);
colIndex.AllowDBNull = false;
colDate.AllowDBNull = false;
colData.AllowDBNull = false;
DataColumn[] keyCols = {colIndex, colDate};
theTable.PrimaryKey = keyCols;
manualForm.dataGrid.ColumnHeadersVisible = true;
manualForm.Show();