J
JJ
Hi all,
I am trying to add records to a Access DB. I use the following code to do
this. The record gets recorded in the db's but when I read the record back
from the database. All fields report nothing. Now here's the clincher. When
I go to Access and do a query for that record in Access it still reports
nothing even though the record is in table. Now when I cut and paste the
record back into same table. wahlah its fine. Am I maybe missing some kind
of commit in this code? Any ideas? How does the code look below to you?
try
{
DataSet dsHours = new DataSet();
System.Data.DataRow drTS;
//Initialize Data Adapter and Dataset for TS Hours Table
daHours.TableMappings.Add("Table", "Hours" );
daHours.Fill(dsHours ,"Hours");
drTS = dsHours.Tables["Hours"].NewRow();
drTS["TSDate"] = dtEndDate.Value;
drTS["EmployeeID"] = tbEmployeeNum.Text.ToString();
drTS["TSMonReg"] = tbMon.Text.ToString();
drTS["TSTuesReg"] = tbTues.Text.ToString();
drTS["TSWedsReg"] = tbWeds.Text.ToString();
drTS["TSThursReg"] = tbThurs.Text.ToString();
drTS["TSFriReg"] = tbFri.Text.ToString();
drTS["TSSatReg"] = tbSat.Text.ToString();
drTS["TSSunReg"] = tbSun.Text.ToString();
drTS["TSMonOT"] = tbMonOT.Text.ToString();
dsHours.Tables[0].Rows.Add(drTS);
daHours.Update(dsHours);
MessageBox.Show("Record Added Successfully !");
bUpdateTS.Visible = true;
bAddTS.Visible = false;
}
catch (OleDbException err)
{
string errorMessage = "Message: " + err.Message + "\n" +
"Source: " + err.Source + "\n" ;
MessageBox.Show(errorMessage,"Error in DataCon");
}
catch(Exception err)
{
MessageBox.Show(err.Message,"General Error");
}
Thanks,
JJ
I am trying to add records to a Access DB. I use the following code to do
this. The record gets recorded in the db's but when I read the record back
from the database. All fields report nothing. Now here's the clincher. When
I go to Access and do a query for that record in Access it still reports
nothing even though the record is in table. Now when I cut and paste the
record back into same table. wahlah its fine. Am I maybe missing some kind
of commit in this code? Any ideas? How does the code look below to you?
try
{
DataSet dsHours = new DataSet();
System.Data.DataRow drTS;
//Initialize Data Adapter and Dataset for TS Hours Table
daHours.TableMappings.Add("Table", "Hours" );
daHours.Fill(dsHours ,"Hours");
drTS = dsHours.Tables["Hours"].NewRow();
drTS["TSDate"] = dtEndDate.Value;
drTS["EmployeeID"] = tbEmployeeNum.Text.ToString();
drTS["TSMonReg"] = tbMon.Text.ToString();
drTS["TSTuesReg"] = tbTues.Text.ToString();
drTS["TSWedsReg"] = tbWeds.Text.ToString();
drTS["TSThursReg"] = tbThurs.Text.ToString();
drTS["TSFriReg"] = tbFri.Text.ToString();
drTS["TSSatReg"] = tbSat.Text.ToString();
drTS["TSSunReg"] = tbSun.Text.ToString();
drTS["TSMonOT"] = tbMonOT.Text.ToString();
dsHours.Tables[0].Rows.Add(drTS);
daHours.Update(dsHours);
MessageBox.Show("Record Added Successfully !");
bUpdateTS.Visible = true;
bAddTS.Visible = false;
}
catch (OleDbException err)
{
string errorMessage = "Message: " + err.Message + "\n" +
"Source: " + err.Source + "\n" ;
MessageBox.Show(errorMessage,"Error in DataCon");
}
catch(Exception err)
{
MessageBox.Show(err.Message,"General Error");
}
Thanks,
JJ