hello,
this is the code i wrote for my application to retrieve values,delete values,update values and insert values...
i am havin doubt in delete and retrieve snippets whether it works right. and deletion should ask for the primarykey which is traderid over here and on getting it,it retrieves all details for the particular user and deletes it. i couldnt check out right now as i dont have connection.
'adodc control
Private Sub Adodc1_WillMove (ByVal adReason As ADODB.EventReas onEnum, adStatus As ADODB.EventStat usEnum, ByVal pRecordset As ADODB.Recordset )
End Sub
'reset all values/clear the values
Private Sub Command9_Click( )
firstname.Text = ""
middlename.Text = ""
lastname.Text = ""
sex.Text = ""
city.Text = ""
state.Text = ""
country.Text = ""
mailid.Text = ""
userid.Text = ""
password.Text = ""
traderid.Text = ""
End Sub
'retrieve contents
Private Sub Command1_Click( )
Dim sql As String
sql = "select * from trader;"
'specify format of SQL result and assisgn to ADODC
Adodc1.CommandT ype = adCmdText
Adodc1.RecordSo urce = sql
Adodc1.Refresh
End Sub
'insert records
Private Sub Command3_Click( )
Adodc1.Recordse t.AddNew
Adodc1.Recordse t.Fields("first name") = firstname.Text
Adodc1.Recordse t.Fields("middl ename") = middlename.Text
Adodc1.Recordse t.Fields("lastn ame") = lastname.Text
Adodc1.Recordse t.Fields("sex") = sex.Text
Adodc1.Recordse t.Fields("city" ) = city.Text
Adodc1.Recordse t.Fields("state ") = state.Text
Adodc1.Recordse t.Fields("count ry") = country.Text
Adodc1.Recordse t.Fields("maili d") = mailid.Text
Adodc1.Recordse t.Fields("useri d") = userid.Text
Adodc1.Recordse t.Fields("passw ord") = password.Text
Adodc1.Recordse t.Fields("trade rid") = traderid.Text
Adodc1.Recordse t.Update
MsgBox "Data inserted and updated"
End Sub
'delete records by retriving the details using traderid details and deleting.
sql = "select firstname,middl ename,lastname, sex,city,state, country,mailid, panno,userid,pa ssword,traderid from trader where traderid=&trade rid;"
If Adodc1.Recordse t.EditMode = adEditDel Then
If MsgBox("Do you really want to delete ?", vbYesNo) = vbYes Then
Adodc.Recordset .Delete
End If
End If
Unload Me
End Sub