In relational database,eg: bank management i want to knw how to update the table in the deposit section, after a run time error is detected,if the account no: does not exist.In my case the control stops in that particular line. It does not go to the next line.So if u can please help me.
Use Ado object and not Ado control for better results. This just gives the hints as how to do it. This code can give errors related to database and so Use more standard code. This is just an illustration of concept as to how to do it. Code: 'Put 2 textbox, 1 command button and one ado controland connect to database which has table name account with 2 fields accno and name where accno is primary key field. Private Sub Command1_Click() On Error GoTo ErrorHandler If flag = False Then 'Change command button caption Command1.Caption = "Save" Else 'Insert the data and check if error occurs on primary key On Error GoTo DatabaseErrorHandler 'Database error Adodc1.RecordSource = "Insert into account values(" + Text1.Text + ",'" + Text2.Text + "');" Adodc1.Refresh On Error GoTo ErrorHandler Command1.Caption = "Add" End If flag = Not flag Exit Sub DatabaseErrorHandler: 'Change the value and insert Text1.Text = "3" Text2.Text = "New Name" Adodc1.RecordSource = "Insert into account values(" + Text1.Text + ",'" + Text2.Text + "');" Adodc1.Refresh ErrorHandler: MsgBox Err.Description, vbCritical + vbOKOnly End Sub