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