Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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"))

  • *Experts*
Posted

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.

Posted
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.
Posted

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

Some people are wise and some are other-wise.

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...