D
Darryn Ross
Hi,
I am having trouble saving my new record to my access database, the dataset
gets updated fine but the new record is not being added to the database for
which it is looking at. Here is my code, any help would be appreciated.
DtlsConnection.ConnectionString = strConnectionPath ;
DtlsConnection.Open() ;
SelectDtlsCommand.CommandText = "Select * From tble" ;
SelectDtlsCommand.Connection = DtlsConnection ;
DtlsAdapter.SelectCommand = SelectDtlsCommand ;
DtlsAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey ;
DtlsAdapter.Fill(DtlsDs, "tble") ;
DataRow tblRow ;
DataTable tbl ;
tbl = DtlsDs.Tables["tble"] ;
tblRow = tbl.NewRow() ;
try {
tblRow["Code"] = txtCode.Text ;
tblRow["Name"] = txtName.Text ;
tblRow["Type"] = txtType.Text ;
tbl.Rows.Add(tblRow) ;
DtlsDs.AcceptChanges() ;
}
catch(Exception e) {
MessageBox.Show(e.Message, "Error Saving Data", MessageBoxButtons.OK,
MessageBoxIcon.Error) ;
}
Kind Regards
Darryn Ross
I am having trouble saving my new record to my access database, the dataset
gets updated fine but the new record is not being added to the database for
which it is looking at. Here is my code, any help would be appreciated.
DtlsConnection.ConnectionString = strConnectionPath ;
DtlsConnection.Open() ;
SelectDtlsCommand.CommandText = "Select * From tble" ;
SelectDtlsCommand.Connection = DtlsConnection ;
DtlsAdapter.SelectCommand = SelectDtlsCommand ;
DtlsAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey ;
DtlsAdapter.Fill(DtlsDs, "tble") ;
DataRow tblRow ;
DataTable tbl ;
tbl = DtlsDs.Tables["tble"] ;
tblRow = tbl.NewRow() ;
try {
tblRow["Code"] = txtCode.Text ;
tblRow["Name"] = txtName.Text ;
tblRow["Type"] = txtType.Text ;
tbl.Rows.Add(tblRow) ;
DtlsDs.AcceptChanges() ;
}
catch(Exception e) {
MessageBox.Show(e.Message, "Error Saving Data", MessageBoxButtons.OK,
MessageBoxIcon.Error) ;
}
Kind Regards
Darryn Ross