ranjit_dutt
Member
- Joined
- Aug 14, 2013
- Messages
- 12
- Programming Experience
- Beginner
hi i have two or more tables with same fields to update in a button click...
i am using this code:
but this give no result all done but not update
please advice
one more thing i would like update is i am using access database for backend
i am using this code:
VB.NET:
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim res As New DialogResult
res = MsgBox("Do you want to save data?", MsgBoxStyle.YesNo, "Client Details")
If res = DialogResult.Yes Then
If Me.txtClientCode.Text = "" Then
MsgBox("ClientCode is Compulsory Field", MsgBoxStyle.Critical, "Client Info")
Else
Save_Record()
Set_Button(2)
res = MsgBox("Do you want to upadate the record in master?", MsgBoxStyle.YesNo, "Client Details")
If res = Windows.Forms.DialogResult.Yes Then
Dim conn As New OleDbConnection
Dim cmd As New OleDbCommand
Try
conn = New OleDbConnection(Get_Constring)
conn.Open()
cmd.Connection = conn
cmd.CommandType = CommandType.Text
Dim sSQL As String = String.Empty
sSQL = "UPDATE PassportApplication SET ClientName=@ClientName WHERE ClientCode=@ClientCode; UPDATE AnnexureA SET ClientName=@ClientName WHERE ClientCode=@ClientCode"
cmd.CommandText = sSQL
cmd.Parameters.Add("@ClientName", OleDbType.VarChar).Value = IIf(Len(Trim(ClientFullName)) > 0, ClientFullName, DBNull.Value)
cmd.Parameters.Add("@ClientCode", OleDbType.VarChar).Value = IIf(Len(Trim(Me.txtClientCode.Text)) > 0, Me.txtClientCode.Text, DBNull.Value)
cmd.ExecuteNonQuery()
MsgBox("Done")
Catch ex As Exception
MsgBox(ErrorToString)
Finally
conn.Close()
End Try
Else
Return
End If
End If
End If
End Sub
but this give no result all done but not update
please advice
one more thing i would like update is i am using access database for backend