Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hey All,

 

I guess this is a short question... i'm trying another way around inserting data into my database... i'm currently trying to load my data into a Dataset and then store it in a database... my question is... i've looked at a couple of code samples to get this done so far... i'm just a little puzzled... in the code samples they don't say where you have to put the SQL Command bit in... could you help me out with this bit..

 

DAdapter.Fill(myDataSet, "PersonalDetails")

myDataRow = myDataSet.Tables.Add("PersonalDetails").NewRow

myDataRow("PatientID") = PatientIDTxt.Text

myDataRow("Name") = NameTxt.Text

myDataSet.Tables("PersonalDetails").Rows.Add(myDataRow)

 

Thanks

~John~

  • *Experts*
Posted

You need to set the 3 properties of the DataAdapter:

UpdateCommand

InsertCommand

DeleteCommand

 

and call the Update method.

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

Also, instead of setting each of those seperatly (UPDATE, INSERT & DELETE) you can use the OleDbCommandBuilder to handle that for you.

 

Something like this...

 

Dim dataAdapter As New OleDbDataAdapter("Select field1, field2, field 3 From YourDB.mdb", con) 
'Put your database connection where 'con' is...
Dim autoGen As New OleDbCommandBuilder(dataAdapter)
'The command builder makes the proper sql statements for 
'you based on the initial select statement that you used 
'when you dimed the adapter

 

Hope it helps...

Being smarter than you look is always better than looking smarter than you are.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...