Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating a Database from a textbox

Status
Not open for further replies.

pkw25

MIS
Mar 20, 2002
46
IE
Hello

I am having a problem where i cant update a database from a text Box. It works if the textbox I am up updating from (textbox3) is not a bound control. But I need to bind it because I want the control to display the current data.
Is there a way of displaying without binding ?
Any help would be much appreciated.

regards
Paraic

Public Sub Form1_Load..................

TextBox1.DataBindings.Add("Text", ds, "tblSPECIALH.ID")
TextBox2.DataBindings.Add("Text", ds, "tblSPECIALH.ENTERED DATE")
TextBox3.DataBindings.Add("Text", ds, "tblSPECIALH.EVENT")


TextBox4.DataBindings.Add("Text", ds, "tblSPECIALH.PARTICIPANT1")
TextBox5.DataBindings.Add("Text", ds, "tblSPECIALH.EVENT")

End Sub



Private Sub UpdatetblSPECIALH(ByVal sqldataadapater4 As SqlDataAdapter)


Dim IDV As Integer = 0
Dim Eve As String = ""

Eve = TextBox3.Text
IDV = TextBox1.Text

Dim Sql As String = String.Format("UPDATE tblSPECIALH SET EVENT = '{0}' WHERE ID = '{1}'", Eve, IDV)
Dim Command2 As SqlCommand = New SqlCommand(Sql, Connection1)

sqldataadapter4.UpdateCommand = Command2

Dim SpeRowToUpdate As DataRow() = ds.Tables("tblSPECIALH").Select(String.Format("ID = '{0}'", IDV))
SpeRowToUpdate(0)("Event") = Eve

Try
sqldataadapter4.Update(ds.Tables("tblSPECIALH"))
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try

End Sub
End Class


 
forum796 is the forum for this one. Read faq222-2244 to see how these forums work best

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top