-1
我創建了一個搜索按鈕來查詢我的MS Access數據庫並顯示結果,但每當我輸入ID並單擊搜索按鈕它什麼也不做。搜索按鈕沒有響應
其他所有工作,它從VB窗體複製數據並將其存儲在MS Access數據庫中,但搜索按鈕不查詢數據庫並檢索數據。
下面是我的搜索按鈕的代碼:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Dim found As Boolean
Try
cm = New OleDb.OleDbCommand
With cm
.Connection = cn
.CommandType = CommandType.Text
.CommandText = "SELECT* FROM tblInfo WHERE (ID = @ID & txtFind.Text = @ID)"
dr = .ExecuteReader
End With
While dr.Read()
found = True
txtFirst1.Text = dr("Pfirst").ToString
txtMid1.Text = dr("Pmiddle").ToString
txtLast1.Text = dr("Plast").ToString
txtAdd1.Text = dr("Paddress").ToString
txtPhone1.Text = dr("Pphone").ToString
txtContact1.Text = dr("Pcontact").ToString
End While
cn.Close()
Exit Sub
If found = False Then MsgBox("Patient ID not found!", MsgBoxStyle.Critical)
dr.Close()
Catch ex As Exception
End Try
我怎樣才能解決這個問題?
你將有一個明顯的錯誤信息,告訴你什麼是錯的,如果你吞嚥的werent例外。請閱讀[問]並參加[旅遊] – Plutonix