What is the Syntaxt to update Database Record in Windows Application? Validate Composite Primary Key ?
-
Dear you are really special to me and you have made good experience in vb.net windows application. I am a beginner. I have a problem to update Database Record from in my Windows application. Hope you may help me. My source table has more than one column have primary key (composite primary key) if I have only one Column set as Primary Key I can update and Delete Database Record. But My Database table using 4 columns as Primary Key how to validate the primary key while checking the record is exist? In Where condition? I write the code below. Pleas help me to solve my small Problem and you will be appreciated. Thanking you. Private Sub Cmd_Save_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Cmd_Save.Click Dim sql As String sql = " Select * From ICECREAM_TRANSACTIONS order by Ice_Seq" Dim Adp_1 As New OleDb.OleDbDataAdapter(sql, Cn_Def) If Status Then If Trim(Me.Comb_IDMASTER.Text) <> Nothing AndAlso IsNumeric(Me.Comb_IDMASTER.Text) Then If Trim(Me.Cmb_Fish_Code.Text) <> Nothing AndAlso IsNumeric(Me.Cmb_ice_Code.Text) Then If Trim(Me.DTP_icecream_DATMASTER.Text) <> Nothing AndAlso IsDate(Me.DTP_icecream_DATMASTER.Text) Then If Trim(Me.CMB_MKT_CODEMASTER.Text) <> Nothing AndAlso IsNumeric(Me.CMB_MKT_CODEMASTER.Text) Then If Not Found_Prim("ICECREAM_TRANSACTIONS", "ICE_SEQ", " & Val(Me.Comb_IDMASTER.Text) & " And "ICE_CODE", "& Val(Me.Cmb_Ice_Code.Text) & " And "ICETRN_DAT", "Me.DTP_ICETRN_DATMASTER.Text" And "MKT_CODE", "& Val(Me.CMB_MKT_CODEMASTER.Text)&") Then CMDS.Exec(Cn_Def, "Insert into ICECREAM_TRANSACTIONS(Ice_Seq,Ice_Code,ICETRN_DAT,MKT_CODE,QTY,WHOLSALE_PRICE,RETAIL_PRICE,NATURE,EXPORT,IMPORT) Values(?,?,?,?,?,?,?,?,?,?)", _ New Object() {Val(Me.Comb_IDMASTER.Text), Val(Me.Cmb_Ice_Code.Text), Me.DTP_ICETRN_DATMASTER.Text, Val(Me.CMB_MKT_CODEMASTER.Text), Val(Me.Txt_QTY.Text), Val(Me.Txt_WHOLSALE_PRICE.Text), Val(Me.Txt_RETAIL_PRICE.Text), Me.TXT_NATURE.Text, Me.CHK_EXPORT.Checked, Me.CHK_IMPORTED.Checked}) MsgBox("New Record Added into the Database " & vbCrLf & "___________" & vbCrLf & vbCrLf & "Insert a New Record", MsgBoxStyle.Information, Me.Text) Clear_Txt() Else CMDS.Exec(Cn_Def, "Update ICE_TRANSACTIONS set I