Private Sub Command1_Click() If Option1 Then Text1.SetFocus Dim result As String Set rs = New ADODB.Recordset Set conn = New ADODB.Connection conn.ConnectionString = "Driver={sql server};server=LIUMIAO;uid=sa;pwd=;database=vbsql" conn.ConnectionTimeout = 30 conn.Open sql = "select * from newcard where sname='" & Trim(Text1.Text) & "'" Set rs = conn.Execute(sql)
If rs.EOF = False Then
Picture1.Print rs.Fields.Item(0); Spc(8); Picture1.Print rs.Fields.Item(1); Spc(8);
Picture1.Print rs.Fields.Item(2); Spc(8); Picture1.Print rs.Fields.Item(3); Spc(8); Picture1.Print rs.Fields.Item(4); Spc(4); Picture1.Print rs.Fields.Item(5); Text1.Text = ""
Else MsgBox "该用户不存在!" End If End If Set rs = Nothing
If Option2 Then Text2.SetFocus
Set rs = New ADODB.Recordset Set conn = New ADODB.Connection conn.ConnectionString = "Driver={sql server};server=LIUMIAO;uid=sa;pwd=;database=vbsql" conn.ConnectionTimeout = 30 conn.Open 'Do While Not rs.EOF sql = "select * from newcard where sno='" & Trim(Text2.Text) & "'" Set rs = conn.Execute(sql) If rs.EOF = False Then
Picture1.Print rs.Fields.Item(0); Spc(8); Picture1.Print rs.Fields.Item(1); Spc(8);
Picture1.Print rs.Fields.Item(2); Spc(8); Picture1.Print rs.Fields.Item(3); Spc(8); Picture1.Print rs.Fields.Item(4); Spc(4); Picture1.Print rs.Fields.Item(5); 'Chr$(13) + Chr$(10) Text2.Text = "" rs.MoveNext
Set rs = Nothing
Else
MsgBox "该用户不存在!" End If
End If
conn.Close End Sub 该代码只能显示一条记录,下一条就显示不出来了 请问该怎么翻盖?谢谢大家