Private Sub Command1_Click()
On Error GoTo EL
If Trim(Text1.Text) = "" Then Exit Sub
Adodc1.RecordSource = "select * from movie"
Adodc1.Refresh
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields(0) = Val(Text1.Text)
Adodc1.Recordset.Fields(1) = Text2.Text
Adodc1.Recordset.Fields(2) = Text3.Text
Adodc1.Recordset.Fields(3) = Text4.Text
Adodc1.Recordset.Fields(4) = Text5.Text
Adodc1.Recordset.Update
MsgBox "บันทึกข้อมูลเรียบร้อยแล้วครับ"
EL:
End Sub
Dim strConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("database/mydatabase.mdb")&";Jet OLEDB:Database Password=;"
'*** Query ***'
Dim Conn As ADODB.Connection
Set Conn = New ADODB.Connection
Set objRec = New ADODB.Recordset
strSQL = "SELECT * FROM.... "
Conn.ConnectionString = strConnectionString
Conn.Open
objRec.Open strSQL, Conn, 1, 3
'*** Execute ***'
Dim Conn As ADODB.Connection
Set Conn = New ADODB.Connection
Conn.ConnectionString = strConnectionString
Conn.Open
strSQL = "INSERT INTO...."
Conn.Execute (strSQL)
If Err.Number <> 0 Then
Exit Function
End If
Conn.Close
Private Sub Combo2_KeyDown(KeyCode As Integer, Shift As Integer)
Set RS = New ADODB.Recordset
RS.Open "select * from Table2 where SN = '" & Combo2.Text & "'", cn, adOpenKeyset, adLockOptimistic
If Not RS.EOF Then
Me.Combo1.Text = RS!Device
End If
RS.Close
Set RS = Nothing
End Sub