gearbolt Posted April 3, 2003 Posted April 3, 2003 I have two text boxes that are bound to a dataset, there is also a Sqlconnection, SqlDataadapter in use. VB.Net generated the Insert, Update and Delete statements for the dataset but I cant figure out how to get the new data out of the textboxes and into the database. This is the code that was generated by Visual Studio. Thanks for the help. 'SqlInsertCommand1 ' Me.SqlInsertCommand1.CommandText = "INSERT INTO dbo.Users(UserName, UserPassword) VALUES (@UserName, @UserPassword); " & _ "SELECT UserName, UserPassword FROM dbo.Users WHERE (UserName = @UserName)" Me.SqlInsertCommand1.Connection = Me.SqlConnection1 Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@UserName", System.Data.SqlDbType.VarChar, 20, "UserName")) Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@UserPassword", System.Data.SqlDbType.VarChar, 20, "UserPassword")) Quote
*Experts* jfackler Posted April 3, 2003 *Experts* Posted April 3, 2003 Do you want to databind the textboxes to the dataset? Or, do you simply want to input the textbox.text into a field in your dataset? The data adapter will take care of implementing the insert command. You simply call an update once you have manipulated your dataset. Quote
Moderators Robby Posted April 3, 2003 Moderators Posted April 3, 2003 Since your textboxes are already bound, there's nothing else to do, simply call the Update method of the DataAdapter. Quote Visit...Bassic Software
gearbolt Posted April 3, 2003 Author Posted April 3, 2003 I have already databinded the textboxes to the dataset. When I hit the the command button to fill the textboxes I get the first record from the database. But know I want to enter some new information into the textbox and update the database. I am new to VB.Net and would not normally use databinding but I am trying to learn everything VB.Net offers. Quote
Moderators Robby Posted April 3, 2003 Moderators Posted April 3, 2003 Yes I know, that's why I said... Since your textboxes are already bound, there's nothing else to do, simply call the Update method of the DataAdapter. Quote Visit...Bassic Software
gearbolt Posted April 4, 2003 Author Posted April 4, 2003 can you post the correct code I should use for the update method. Thanks Quote
*Experts* jfackler Posted April 5, 2003 *Experts* Posted April 5, 2003 oledbdataadapter.update(dataset, "table") Quote
sizer Posted April 8, 2003 Posted April 8, 2003 the rowstate is changed only when u move off the current row. so if u change the value in the textbox, move to the next row, and then examine the rowstate property, u will find that it has indeed changed to "Modified" To cause the rowstate to change without moving off the row, call the EndCurrentEdit method on the underlying bindingcontext object that u create, or if u've not specifically created a bindingcontext, use the following syntax (possibly in the click event of the OK/Save button) Me.BindingContext(dataset, "tablename").EndCurrentEdit Quote Some people are wise and some are other-wise.
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.