G
Gary
I have a form that takes one Contact record and edit's it. The routine used
is as follows:
Private Sub ContactMain_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim strSQL As String
strSQL = "Select * from Contact WHERE sysID = '" & g_sysID & "'"
objDS.Clear()
Dim selectCommand As New SqlClient.SqlCommand(strSQL)
DA.SelectCommand = selectCommand
DA.SelectCommand.Connection = CN
DA.Fill(objDS, "Contact")
Me.txtFirstName.DataBindings.Add("Text", objDS,
"Contact.first_name")
Me.txtLastName.DataBindings.Add("Text", objDS, "Contact.Last_name")
Me.txtAddress1.DataBindings.Add("Text", objDS, "Contact.con1_02_03")
Me.txtPhone.DataBindings.Add("Text", objDS, "Contact.Phone1")
Me.txtCity.DataBindings.Add("Text", objDS, "Contact.con1_02_05")
Me.txtState.DataBindings.Add("Text", objDS, "Contact.con1_02_06")
Me.txtZip.DataBindings.Add("Text", objDS, "Contact.con1_02_07")
Me.txtEMail.DataBindings.Add("Text", objDS, "Contact.con1_03_01")
End Sub
This works fine and the fields get populated. When I want to update the
record I hit the "Save" button and execute the following:
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSave.Click
Try
Dim rows As Integer
DA.ContinueUpdateOnError = True
rows = DA.Update(objDS, "Contact")
If rows > 0 Then
MsgBox("Data updated")
Else
MsgBox("Data Not Updated")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
I get the message saying that the data is not updated. Any help would be
appreciated.
Thanks,
Gary
is as follows:
Private Sub ContactMain_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim strSQL As String
strSQL = "Select * from Contact WHERE sysID = '" & g_sysID & "'"
objDS.Clear()
Dim selectCommand As New SqlClient.SqlCommand(strSQL)
DA.SelectCommand = selectCommand
DA.SelectCommand.Connection = CN
DA.Fill(objDS, "Contact")
Me.txtFirstName.DataBindings.Add("Text", objDS,
"Contact.first_name")
Me.txtLastName.DataBindings.Add("Text", objDS, "Contact.Last_name")
Me.txtAddress1.DataBindings.Add("Text", objDS, "Contact.con1_02_03")
Me.txtPhone.DataBindings.Add("Text", objDS, "Contact.Phone1")
Me.txtCity.DataBindings.Add("Text", objDS, "Contact.con1_02_05")
Me.txtState.DataBindings.Add("Text", objDS, "Contact.con1_02_06")
Me.txtZip.DataBindings.Add("Text", objDS, "Contact.con1_02_07")
Me.txtEMail.DataBindings.Add("Text", objDS, "Contact.con1_03_01")
End Sub
This works fine and the fields get populated. When I want to update the
record I hit the "Save" button and execute the following:
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSave.Click
Try
Dim rows As Integer
DA.ContinueUpdateOnError = True
rows = DA.Update(objDS, "Contact")
If rows > 0 Then
MsgBox("Data updated")
Else
MsgBox("Data Not Updated")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
I get the message saying that the data is not updated. Any help would be
appreciated.
Thanks,
Gary