2

这是代码;

Private Sub txtNProdname_Click()

Set Rs = New ADODB.Recordset

With Rs
.ActiveConnection = Conn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockPessimistic
.Source = "SELECT proddescription FROM products WHERE prodsupplier=" & "'" &       txtNsupplier.Text & "' AND prodname=" & "'" & txtNProdname.Text & "'"
.Open

 txtNdescription.Text = Rs("proddescription")

 End With

End Sub

错误:

Either BOF or EOF is True, or the current record has been deleted.Requested operation requires a current record.

曹帮帮我?似乎没有AND它会起作用,但是当我把它放进去时,就会发生错误。

4

1 回答 1

4

打开记录集后,您需要在使用它之前移动到第一条记录:

Rs.Open
If Rs.EOF = False Then
   Rs.MoveFirst
   txtNdescription.Text = Rs("proddescription")
End If
于 2013-03-24T15:06:25.093 回答