我用vb做的一个窗体输入用户名密码登陆,用户名和密码都来自数据库中members表,但老是提示loop缺少do
PrivateSubCommand2_Click()DimconnAsADODB.ConnectionDimrstAsADODB.RecordsetSetconn=New...
Private Sub Command2_Click() Dim conn As ADODB.Connection Dim rst As ADODB.Recordset Set conn = New ADODB.Connection conn.ConnectionString = "provider=msdasql;driver={sql server};server=HC-VAIO;uid=hc;pwd=hc;database=eshop"conn.Open
Set rst = conn.Execute("select m_account,m_password from members ")
Do While Not rst.EOF If Text1.Text = rst.Fields(0) Then If Text2.Text = rst.Fields(1) Then Me.Hide Form2.Show rst.MoveNextLoop End If End If conn.Close End Sub
Private Sub Comm
and1_Click() Unload MeEnd Sub 展开
Set rst = conn.Execute("select m_account,m_password from members ")
Do While Not rst.EOF If Text1.Text = rst.Fields(0) Then If Text2.Text = rst.Fields(1) Then Me.Hide Form2.Show rst.MoveNextLoop End If End If conn.Close End Sub
Private Sub Comm
and1_Click() Unload MeEnd Sub 展开
1个回答
展开全部
loop 移到两个end if 后面。不过这段代码有点……
改成这样简单点,不用循环
Set rst = conn.Execute("select m_account,m_password from members where 姓名字段='"& text1.text &"' and 密码字段='" & text2.text &"' ")
if rst.eof=false or rst.bof=false then
me.hide
form2.show
改成这样简单点,不用循环
Set rst = conn.Execute("select m_account,m_password from members where 姓名字段='"& text1.text &"' and 密码字段='" & text2.text &"' ")
if rst.eof=false or rst.bof=false then
me.hide
form2.show
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询