G
Gary Paris
Cor,
I made the changes you suggested by I get an error message saying "Incorrect
syntax near the keyword 'trigger'.
What is wrong?
------------------------------ Last message from
4/17/05 -----------------------
Gary,
There are at least two things what makes that your update does not work.
You are have no commands in your dataadapter.
You use the acceptchanges wrong.
I have made some corrections typed (so watch typos) inline in this message
so look below to them.
You better create and dispose better as well the connection in those
procedures because now you don't free the connectionpool.
dim cb as new sqlclient.sqlcommandbuilder(db)
delete the row above, this means that all rowstates which are set to a
changed state will be set to unchanged and the changes are accepted, so the
dataadapter has nothing to change. It is implicitly done by the dataadapter
when a change is done.
I hope this helps,
Cor
I made the changes you suggested by I get an error message saying "Incorrect
syntax near the keyword 'trigger'.
What is wrong?
------------------------------ Last message from
4/17/05 -----------------------
Gary,
There are at least two things what makes that your update does not work.
You are have no commands in your dataadapter.
You use the acceptchanges wrong.
I have made some corrections typed (so watch typos) inline in this message
so look below to them.
You better create and dispose better as well the connection in those
procedures because now you don't free the connectionpool.
----------------------------------------------------------------------------
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim strSQL As String = "Select * from Contact where sysid = '" &
g_sysID & "'"
DB = New SqlClient.SqlDataAdapter(strSQL, CN)
dim cb as new sqlclient.sqlcommandbuilder(db)
ES.Clear()
DB.Fill(ES, "Contact")
If ES.Tables("Contact").Rows.Count > 0 Then
txtAddress.Text =
ES.Tables("Contact").Rows(0).Item("con1_02_03")
txtFirst_Name.Text =
ES.Tables("Contact").Rows(0).Item("First_Name")
txtLast_Name.Text =
ES.Tables("Contact").Rows(0).Item("Last_Name")
End If
End Sub
--------------------------------------------------------------------------
Here is the code to update the table
--------------------------------------------------------------------------
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpdate.Click
Try
es.Tables(0).Rows(0).Item("First_Name") = txtFirst_Name.Text
es.Tables(0).Rows(0).Item("Last_Name") = txtLast_Name.Text
es.Tables(0).Rows(0).Item("con1_02_03") = txtAddress.Text
ES.AcceptChanges()
delete the row above, this means that all rowstates which are set to a
changed state will be set to unchanged and the changes are accepted, so the
dataadapter has nothing to change. It is implicitly done by the dataadapter
when a change is done.
DB.Update(ES, "Contact")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
I hope this helps,
Cor