1,451
社区成员
发帖
与我相关
我的任务
分享
Private Sub Command1_Click()
Dim strSql As String
If Text1.Text <> "" Then
Adodc1.Recordset.Close
If Val(Text1.Text) > 0 Then
strSql = "select * from table1 where num=" & Trim(Text1.Text)
Else
strSql = "select * from table1 where name='" & Trim(Text1.Text) & "'"
End If
Adodc1.CommandType = adCmdText
Adodc1.Recordset.Open strSql
Set DataGrid1.DataSource = Adodc1
Else
Set DataGrid1.DataSource = Nothing
End If
End Sub
Private Sub Command1_Click()
Dim strSql As String
If Text1.Text <> "" Then
If Val(Text1.Text) > 0 Then
strSql = "select * from table1 where num=" & Trim(Text1.Text)
Else
strSql = "select * from table1 where [name]='" & Trim(Text1.Text) & "'"
End If
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = strSql
Set DataGrid1.DataSource = Adodc1
Adodc1.Refresh
Else
Set DataGrid1.DataSource = Nothing
End If
End Sub
Private Sub Form_Load()
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=[你的数据库文件路径和文件名];Persist Security Info=False"
End Sub