1
使用VB 6和adodb連接,當我點擊搜索id時,會出現一個inputbox,當它找到我想要的id時,它會自動將該行的所有數據插入到它們的相應的文本框。搜索數據庫並將其放入文本框
在這裏,我的代碼,在某些時候,它不起作用,我不記得錯誤,但我會在這裏發佈它,當我回到家,感謝您的幫助球員。
Private Sub cmdsearch_Click()
findemployee = InputBox("Insert Employee ID")
record.Open ("select * from employees where ID='" & findemployee & "'"), conn, 3, 3
If record.EOF Then
MsgBox "NO" & findemployee & " ID WAS NOT FOUND!", vbCritical + vbOKOnly, "Error Search"
Set record = Nothing
Else
txtemployeeid.Text = record!ID
txtlnames.Text = record!lastname
txtfnames.Text = record!Firstname
txtmnames.Text = record!middlename
cmbgenders.Text = record!gender
bdates.Value = record!birthdate
txtbplaces = record!birthplace
txtages = record!age
txtaddress.Text = record!address
cmbeducattainments.Text = record!educattainment
txtnos.Text = record!contactno
cstarts.Value = record!contractstart
cends.Value = record!contractend
Set record = Nothing
End If
End Sub
我想你一定循環記錄搜索... – MAC
是'findemployee'一個'text'或'numeric'值。如果是數字,則不應該在其周圍使用引號(''')。 –
'record.MoveFirst'也可能需要。 –