
Private Sub Command1_Click()
'搜索管理員功能實作
If Text1.Text <> 0 Then
Adodc1.recordsourse = "select * from 管理員索引表 where 管理員用戶名=Text1.Text"
Else
Adodc1.RecordSource = "select * from 管理員索引表 where 姓名=Text1.Text"
End Sub
adodc1已經與圖書館管理系統進行了連接,adodc1的recordsource是管理員索引表
怎么改改代碼可以查詢出所需的記錄并把記錄顯示在datagrid里????
uj5u.com熱心網友回復:
說實話,你發的這種來歷不明的代碼,真不像是認真學過編程的人寫的,哪怕是像我這下改一下都要靠譜不少啊:Option Explicit
Public Function QuotedStr(ByVal sValue As String) As String
QuotedStr = "'" & Replace(sValue, "'", "''") & "'"
End Function
Private Sub Command1_Click()
'搜索管理員功能實作
If Len(Text1.Text) <> 0 Then
Adodc1.recordsourse = "select * from 管理員索引表 where 管理員用戶名=" & QuotedStr(Text1.Text)
ElseIf Len(Text2.Text) <> 0 Then
Adodc1.RecordSource = "select * from 管理員索引表 where 姓名=" & QuotedStr(Text2.Text)
End Sub
uj5u.com熱心網友回復:
樓上正解,這種問題只要在debug里面把你的sql陳述句列印出來看一看就知道錯在哪里了uj5u.com熱心網友回復:
Adodc1.recordsourse = "select * from 管理員索引表 where 管理員用戶名='"& Text1.Text &"'"轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/142442.html
標籤:VB基礎類
