vb編程搜索access資料為什么顯示空白,程式除錯沒有發生錯誤
程式內容如下:
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
問題出在哪里?為什么搜索后插件里顯示的是空白的
uj5u.com熱心網友回復:
這是體育老師教的編程?不要直接操作 Adodc1.Recordset,會影響正常的功能!!!
uj5u.com熱心網友回復:
一個問題發N多個帖子,這種人是不是有點心理變態?這個版塊根本就沒什么人氣,難道還擔心帖子“被淹沒”嗎!!!
uj5u.com熱心網友回復:
憤青從來不缺存在感!
uj5u.com熱心網友回復:
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
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/57483.html
標籤:控件
上一篇:vb 制作服務器和客戶端的問題
下一篇:vb翻牌記憶游戲設計
