Another way around inserting data into my MS Access Database

Joined
Aug 3, 2002
Messages
19
Hey All,

I guess this is a short question... im trying another way around inserting data into my database... im currently trying to load my data into a Dataset and then store it in a database... my question is... ive looked at a couple of code samples to get this done so far... im just a little puzzled... in the code samples they dont 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~
 
You need to set the 3 properties of the DataAdapter:
UpdateCommand
InsertCommand
DeleteCommand

and call the Update method.

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

Something like this...

Code:
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...
 
Back
Top