when I edit the record with the following code
Try
If EditClick = True Then
SqlQuery = "update Ledgers set Name = '" & TxtName.Text & "',Grp = '" & CmbGrp.Text & "',Add1= '" & TxtAdd1.Text & "',Add2= '" & TxtAdd2.Text & "',City = '" & CmbCity.Text & "',Dist ='" & TxtDist.Text & "',Pincode ='" & TxtPIN.Text & "',State ='" & DBState.Text & "',Email ='" & TxtEmail.Text & "',Landline ='" & TxtPhone.Text & "',Mobile ='" & TxtMob.Text & "',VATNO ='" & TxtVAT.Text & "',CSTNO ='" & TxtCST.Text & "',GSTNO = '" & TxtGST.Text & "',PAN ='" & TxtPAN.Text & "' where cust_id = '" & TxtCustID.Text & "'"
Sqlcommand = New MySqlCommand(SqlQuery, Conn)
Reader = Sqlcommand.ExecuteReader
Reader.Close()
Else
SqlQuery = "insert into Ledgers (Name,Grp,Add1,Add2,City,Dist,Pincode,State,Email,Landline,Mobile,VATNO,CSTNO,GSTNO,PAN) values ('" & TxtName.Text & "' , '" & CmbGrp.Text & "' , '" & TxtAdd1.Text & "' , '" & TxtAdd2.Text & "' , '" & CmbCity.Text & "' , '" & TxtDist.Text & "' , '" & TxtPIN.Text & "' , '" & DBState.Text & "' , '" & TxtEmail.Text & "' , '" & TxtPhone.Text & "' , '" & TxtMob.Text & "' , '" & TxtVAT.Text & "' , '" & TxtCST.Text & "' , '" & TxtGST.Text & "' , '" & TxtPAN.Text & "')"
Sqlcommand = New MySqlCommand(SqlQuery, Conn)
Reader = Sqlcommand.ExecuteReader
Reader.Close()
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
DisableTxt(Me)
EnableBtn(Me)
BtnSave.Enabled = False
BtnAdd.Enabled = True
BtnAdd.Focus()
BtnExit.Enabled = True
Reader.Close()
Ledgers()
EditClick = False
I see both records(edited and old) on form.
If my table has 10 records , I see 20 records(extra entry of all entries)
Suppose if i edit my record from "JAMEER" to "JAMEER MULLA" i see both entries
when I exit and again start my application everything id Ok.
What I have tried:
I tried to refresh the dataset, but could not find the command to refres it.