nkwk Posted March 11, 2004 Posted March 11, 2004 If i connect to an sql server using Connection1 Adapter1 Dataset1 I want to save a new record that I have added. so --Fill on form load-- adapter1.fill(dataset,"testdb") --Click the AddNew Button-- Me.BindingContext(DataSet1, "testdb").CancelCurrentEdit() Me.BindingContext(DataSet1, "testdb").AddNew() *fill in my fields on the form (which are bound to the dataset)* I now want to update the sql server so I thought it would be a simple --Update-- adapter1.update(dataset1,"testdb") But that doesnt work. :( Please can someone help me with my dataset? Nick Quote
Administrators PlausiblyDamp Posted March 11, 2004 Administrators Posted March 11, 2004 When you say it doesn't work - could you give a few more details? What error (if any do you get)? Also have you defined an UpdateCommand in the DataAdapter? If not you will need to. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
nkwk Posted March 11, 2004 Author Posted March 11, 2004 Oh Dear I'm a bit lost now. Basically the problem is that I can create a new record etc in the dataset but then when you hit save it isnt updating the sql server. So if you exit and re-open the application the changes are gone because the dataset has been wiped. Ive just discovered that I haven't specified the Update Command Text which is obviously the source of the problem. Newbie Time, I dont know how to write an update command string My select string: SELECT ID, [Telephone ], [MCCB number ], , Surname, Firstname, [Company Name], [Ad line 1], [Ad line 2], [Ad line 3], [Ad line 4], Postcode, [introduced by], [Date Added], [Come from] FROM mailinglist if i wanted to say update ID from textbox1 (which is bound to the ID field) how do i specify that? UPDATE mailinglist SET ID=? Kind Regards, Nick Quote
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.