Click here to Skip to main content
16,006,065 members
Home / Discussions / C#
   

C#

 
GeneralRe: Creating a binary file Pin
Ista4-Apr-04 15:43
Ista4-Apr-04 15:43 
GeneralRe: Creating a binary file Pin
leppie5-Apr-04 7:12
leppie5-Apr-04 7:12 
GeneralRe: Creating a binary file Pin
Ista5-Apr-04 9:22
Ista5-Apr-04 9:22 
GeneralRe: Creating a binary file Pin
leppie3-Apr-04 11:12
leppie3-Apr-04 11:12 
GeneralRe: Creating a binary file Pin
Ista3-Apr-04 11:33
Ista3-Apr-04 11:33 
GeneralNumeric bases types Pin
Roger H. Art3-Apr-04 7:29
sussRoger H. Art3-Apr-04 7:29 
GeneralRe: Numeric bases types Pin
leppie3-Apr-04 7:52
leppie3-Apr-04 7:52 
GeneralAdding Recs to DB Pin
MrJJKoolJ3-Apr-04 4:52
MrJJKoolJ3-Apr-04 4:52 
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 heres 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?

<br />
try <br />
{ <br />
    <br />
   DataSet dsHours = new DataSet(); <br />
   System.Data.DataRow drTS; <br />
   //Initialize Data Adapter and Dataset for TS Hours Table <br />
    daHours.TableMappings.Add("Table", "Hours" ); <br />
    daHours.Fill(dsHours ,"Hours"); <br />
<br />
   drTS = dsHours.Tables["Hours"].NewRow(); <br />
   drTS["TSDate"] = dtEndDate.Value; <br />
   drTS["EmployeeID"] = tbEmployeeNum.Text.ToString(); <br />
   drTS["TSMonReg"] = tbMon.Text.ToString(); <br />
   drTS["TSTuesReg"] = tbTues.Text.ToString(); <br />
   drTS["TSWedsReg"] = tbWeds.Text.ToString(); <br />
   drTS["TSThursReg"] = tbThurs.Text.ToString(); <br />
   drTS["TSFriReg"] = tbFri.Text.ToString(); <br />
   drTS["TSSatReg"] = tbSat.Text.ToString(); <br />
   drTS["TSSunReg"] = tbSun.Text.ToString(); <br />
   drTS["TSMonOT"] = tbMonOT.Text.ToString(); <br />
   dsHours.Tables["Hours"].Rows.Add(drTS); <br />
<br />
   daHours.Update(dsHours); <br />
   MessageBox.Show("Record Added Successfully !"); <br />
   bUpdateTS.Visible = true; <br />
   bAddTS.Visible = false; <br />
} <br />
   catch (OleDbException   err) <br />
{ <br />
   string errorMessage = "Message: " + err.Message + "\n" + <br />
   "Source: " + err.Source + "\n" ; <br />
   MessageBox.Show(errorMessage,"Error in DataCon"); <br />
} <br />
  catch(Exception err) <br />
{ <br />
  MessageBox.Show(err.Message,"General Error"); <br />
} <br />
<br />


This is for an insert into the Access DB. I use commandbuilder to build the insert into the Access DB. It automatically generates the insert statement for me. Is it possible to assign my own SQL Insert string to the DataAdapters InsertCommand instead? Or is the one generated by the COmmandbuilder more efficient even though it doesn't work properly? Also how can I check to see what the version is for Jet 4 oledb is? Should I use maybe ODBC connection string to the Access DB instead, maybe more reliable? What do you guys think? How can I tell if I have the latest data drivers for .net?


Thanks,
JJ
GeneralLOC Question Pin
Brian Delahunty3-Apr-04 4:28
Brian Delahunty3-Apr-04 4:28 
GeneralRe: LOC Question Pin
Heath Stewart3-Apr-04 4:34
protectorHeath Stewart3-Apr-04 4:34 
GeneralRe: LOC Question Pin
Nick Parker3-Apr-04 4:39
protectorNick Parker3-Apr-04 4:39 
GeneralRe: LOC Question Pin
Brian Delahunty3-Apr-04 4:49
Brian Delahunty3-Apr-04 4:49 
GeneralRe: LOC Question Pin
Nick Parker3-Apr-04 4:37
protectorNick Parker3-Apr-04 4:37 
Generalmultiframe gif Pin
Stephane David3-Apr-04 1:40
Stephane David3-Apr-04 1:40 
GeneralRe: multiframe gif Pin
Heath Stewart3-Apr-04 4:29
protectorHeath Stewart3-Apr-04 4:29 
GeneralRe: multiframe gif Pin
Stephane David3-Apr-04 5:06
Stephane David3-Apr-04 5:06 
GeneralRe: multiframe gif Pin
Heath Stewart3-Apr-04 6:09
protectorHeath Stewart3-Apr-04 6:09 
GeneralRe: multiframe gif Pin
Stephane David3-Apr-04 7:28
Stephane David3-Apr-04 7:28 
GeneralProblem using Device Handle with P/Invoke methods Pin
Tristan Rhodes3-Apr-04 0:46
Tristan Rhodes3-Apr-04 0:46 
GeneralRe: Problem using Device Handle with P/Invoke methods Pin
Heath Stewart3-Apr-04 3:33
protectorHeath Stewart3-Apr-04 3:33 
GeneralRe: Problem using Device Handle with P/Invoke methods Pin
Tristan Rhodes3-Apr-04 4:14
Tristan Rhodes3-Apr-04 4:14 
GeneralRe: Problem using Device Handle with P/Invoke methods Pin
Heath Stewart3-Apr-04 4:32
protectorHeath Stewart3-Apr-04 4:32 
GeneralRe: Problem using Device Handle with P/Invoke methods Pin
leppie3-Apr-04 6:35
leppie3-Apr-04 6:35 
GeneralShutting Down Windows Pin
Nagendra Kamath K2-Apr-04 23:32
Nagendra Kamath K2-Apr-04 23:32 
GeneralRe: Shutting Down Windows Pin
Dave Kreskowiak3-Apr-04 2:11
mveDave Kreskowiak3-Apr-04 2:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.