标题:登录功能无法实现
取消只看楼主
yuiolivia
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2005-12-5
 问题点数:0 回复次数:3 
登录功能无法实现

Dim conn As New SqlConnection("server=.;database=login;integrated security=sspi")
Dim comm As New SqlCommand
Dim ds As New DataSet
Dim da As New SqlDataAdapter
Dim user, password As String
user = ComboBox1.Text
password = TextBox1.Text
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
comm.Connection = conn
comm.CommandType = CommandType.Text
comm.CommandText = "select * from Login where username = '" & user & "' and password = '" & password & "'"
da.SelectCommand = comm
If comm.CommandType <> 0 Then
MessageBox.Show("GO!")
Else
MessageBox.Show("NO!")
ComboBox1.Text = ""
TextBox1.Text = ""
ComboBox1.Focus()
Me.Focus()
End If
conn.Close()
这是button里的代码,为什么无论密码对错都是“GO”啊?
大家指点一下!谢谢~

搜索更多相关主题的帖子: 登录 
2006-11-10 20:33
yuiolivia
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2005-12-5
得分:0 
那应该怎么改啊?
2006-11-10 20:57
yuiolivia
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2005-12-5
得分:0 
comm.Connection = conn
comm.CommandType = CommandType.Text
comm.CommandText = "select * from Login where username = '" & user & "' and password = '" & password & "'"
da.SelectCommand = comm
'da.Fill(ds)
If comm.ExecuteNonQuery > 0 Then
MessageBox.Show("GO!")
Else
MessageBox.Show("NO!")
ComboBox1.Text = ""
TextBox1.Text = ""
ComboBox1.Focus()
Me.Focus()
End If
conn.Close()

改了以后就只显示NO了无论输什么密码~
2006-11-12 09:11
yuiolivia
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2005-12-5
得分:0 
还是不行!这是全部代码:
Dim user, password As String
user = ComboBox1.Text.Trim
password = TextBox1.Text.Trim
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
comm.Connection = conn
comm.CommandType = CommandType.Text
comm.CommandText = "select * from Login where username = '" & user & "' and password = '" & password & "'"
da.SelectCommand = comm
da.Fill(ds)
If comm.ExecuteNonQuery > 0 Then
MessageBox.Show("GO!")
Else
MessageBox.Show("NO!")
ComboBox1.Text = ""
TextBox1.Text = ""
ComboBox1.Focus()
Me.Focus()
End If
conn.Close()
2006-11-12 21:24



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-102091-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.096503 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved