Home > Software engineering >  VB access operation problem, thank you!
VB access operation problem, thank you!

Time:10-14

Dim Cn As New ADODB. Connection
Dim Rst As New ADODB. You

Private Sub Form_Load () 'load display table
Dim SqlStr As String
SqlStr="Select * From table 1"
The Query (SqlStr)
End Sub

Private Sub Query (strInput As String)
Cn. The Open ". The Provider=Microsoft Jet. The OLEDB. 4.0; Data Source="& amp; App. The Path & amp; "\ db2. MDB; Persist Security Info=False "
Rst. CursorLocation=adUseClient
Rst. Open strInput, Cn, adOpenDynamic adLockOptimistic, adCmdText 'Open recordset
Set DataGrid1. The DataSource to DataGrid modify data source=Rst '
End Sub

Private Sub Command2_Click () query
'Dim SqlStr As String
SqlStr="Select * From table 1 where name='" & amp; Text2. Text & amp; "'
"The Query (SqlStr)
End Sub

Private Sub Command4_Click () add
'Rst. AddNew
End Sub

Private Sub Command4_Click () add
'Rst. Delete
End Sub


The above procedure can realize to add, delete, etc., but can't realize the query, please help me to modify it, thank you

CodePudding user response:

Private Sub Command2_Click () query
'Dim SqlStr As String
SqlStr="Select * From table 1 where name='" & amp; Text2. Text & amp; "'
"Rst. Close
Cn. Close
The Query (SqlStr)
End Sub
  • Related