databinding a textbox in a webform

N

Nikerz Inc

Hi there,

I want to bind a text box to a column in my dataset and update changes vice
versa. I'm having a rough time to do so any help or examples appreciated!!

Dim sql As String = "SELECT * FROM Consumer WHERE Consumer.ConsumerID = " &
CustomerID

Dim updatesql As String = "Update set consumer.firstname = " & TextBox1.Text
& " WHERE Consumer.ConsumerID = " & CustomerID

Dim MyOleDbConn As New OleDbConnection(connstr)

Dim myOleDbCmd As New OleDbCommand(sql, MyOleDbConn)

Dim myadapter As New OleDbDataAdapter()



Dim myds As New DataSet()

Dim mytable As DataTable

Dim myrow As DataRow

myadapter.UpdateCommand = New OleDbCommand(updatesql, MyOleDbConn)

myadapter.SelectCommand = New OleDbCommand(sql, MyOleDbConn)

MyOleDbConn.Open()

myadapter.Fill(myds, "Consumer")

If myds.Tables(0).Rows.Count > 0 Then

TextBox1.Text = myds.Tables(0).Rows(0).Item("FirstName")

End If

myrow("FirstName") = "test"

myadapter.Update(myds, "Consumer")

DataGrid1.DataSource = myds

DataGrid1.DataBind()

MyOleDbConn.Close()

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,176
Latest member
Jerilyn201
Top