G
Gary
I have been trying to update a record that I edited and can't seem to figure
out what I'm missing. Here is the code that I have to load the record on
the form:
'
****************************************************************************
*****************
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 cmb As SqlClient.SqlCommandBuilder = New
SqlClient.SqlCommandBuilder(DA)
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.txtFullName.DataBindings.Add("Text", objDS, "Contact.full_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
And here is the code for the update:
'
****************************************************************************
*****************
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSave.Click
Try
DirectCast(BindingContext(objDS.Tables(0)),
CurrencyManager).EndCurrentEdit()
Me.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
What am I missing? Do I need to code the INSERT, UPDATE, and DELETE command
and if so, where do I put them? I have nine fields that I'm working with so
please help me update my record. Any code examples would be appreciated.
Thanks,
Gary
out what I'm missing. Here is the code that I have to load the record on
the form:
'
****************************************************************************
*****************
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 cmb As SqlClient.SqlCommandBuilder = New
SqlClient.SqlCommandBuilder(DA)
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.txtFullName.DataBindings.Add("Text", objDS, "Contact.full_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
And here is the code for the update:
'
****************************************************************************
*****************
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSave.Click
Try
DirectCast(BindingContext(objDS.Tables(0)),
CurrencyManager).EndCurrentEdit()
Me.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
What am I missing? Do I need to code the INSERT, UPDATE, and DELETE command
and if so, where do I put them? I have nine fields that I'm working with so
please help me update my record. Any code examples would be appreciated.
Thanks,
Gary