Saturday, August 22, 2009

how to search and delete a record in vb6

Option Explicit


Private Sub cmdSearch_Click()

Adodc1.RecordSource = "SELECT * FROM tblStudent where Lastname = ' " '& Text1.Text & " ' "
Adodc1.Refresh

If Adodc1.Recordset.RecordCount = 0 Then
'Timer1.Enabled = True
MsgBox "type the lastname to search wala"
End If

End Sub


Private Sub cmdDelete_Click()

Prompt$ = "Do you really want to delete?"
reply = MsgBox(Prompt$, vbOKCancel, "Delete Record")

If reply = vbOK Then
    Adodc1.Recordset.Delete
    Adodc1.Recordset.MoveNext
End If

End Sub

1 comment:

Unknown said...

import javax.swing.JOptionPane;

public class JOptionPaneTest2 {
public static void main(String[] args) {
//... Text to put on the buttons.
String[] choices = {"Democratic", "Republican", "None of your business", "Quit"};

//... Variables to keep track of the counts.
int democraticCount = 0;
int republicanCount = 0;
int noAnswerCount = 0;

//... "Infinite" loop, terminated by call to System.exit(0)
while (true) {
int response = JOptionPane.showOptionDialog(
null // Center in window.
, "How did you vote?" // Message
, "Party Poll" // Title in titlebar
, JOptionPane.YES_NO_OPTION // Option type
, JOptionPane.PLAIN_MESSAGE // messageType
, null // Icon (none)
, choices // Button text as above.
, "None of your business" // Default button's label
);

//... Use a switch statement to check which button was clicked.
switch (response) {
case 0:
democraticCount++;
break;
case 1:
republicanCount++;
break;
case 2:
noAnswerCount++;
break;
case 3:
case -1:
//... Both the quit button (3) and the close box(-1) handled here.
System.exit(0); // It would be better to exit loop, but...
default:
//... If we get here, something is wrong. Defensive programming.
JOptionPane.showMessageDialog(null, "Unexpected response " + response);
}

//... Display the accumulated results so far.
JOptionPane.showMessageDialog(null, "Response = " + response
+ "\nDem = " + democraticCount
+ "\nRep = " + republicanCount
+ "\nOther = " + noAnswerCount);
}
}
}