Silv3rSurf3r_20 Posted June 6, 2003 Posted June 6, 2003 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~ Quote
*Experts* Nerseus Posted June 6, 2003 *Experts* Posted June 6, 2003 You need to set the 3 properties of the DataAdapter: UpdateCommand InsertCommand DeleteCommand and call the Update method. -Nerseus Quote "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
Mothra Posted June 6, 2003 Posted June 6, 2003 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... Quote Being smarter than you look is always better than looking smarter than you are.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.