有一段登录的代码,帮忙给看看吧,很急
高手们:程序如下,帮忙看看行不?
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnOk.Click
If Me.ComboBox1.Text = "" Or Me.u_password.Text = "" Then
MsgBox("请输入用户名和密码!")
Else
Try
Me.SqlConnection1.Open()
Dim reader As SqlDataReader
Dim comd As New SqlCommand
Dim str As String
str = "select u_password from user where u_department='" + Me.ComboBox1.SelectedText()+ "'"
comd.CommandText = str
comd.Connection = Me.SqlConnection1
reader = comd.ExecuteReader()
If Not reader.Read() Then
MsgBox("不存在此用户!", MsgBoxStyle.OKOnly)
Me.ComboBox1.Text = ""
Me.u_password.Text = ""
Else
If reader("u_password").ToString = Me.u_password.Text Then
Dim main As New main
main.Show()
Me.Hide()
Else
MsgBox("密码错误!", MsgBoxStyle.Exclamation)
Me.ComboBox1.Text = ""
Me.u_password.Focus()
End If
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
Me.SqlConnection1.Close()
End Sub
急等着用
谢谢! --------------------编程问答-------------------- 写的很土,这样子写完一个系统会累死人的
asp.net C# 技术群:39921387 群刚成立,欢迎热爱学习人士共同研究探讨。希望加入都对:信息采集,搜索引擎,数据,易做图等感兴趣 --------------------编程问答-------------------- 您帮我看看
或者给我一段登录的代码行吗
我很急用
谢了 --------------------编程问答-------------------- 自己顶一下能不能快点啊 --------------------编程问答-------------------- 有什么问题么? --------------------编程问答-------------------- str = "select u_password from user where u_department='" + Me.ComboBox1.SelectedText()+ "'"
================================================
str = "select u_password from [user] where u_department='" + Me.ComboBox1.SelectedText()+ "'"
--------------------编程问答-------------------- 问题已经解决了
谢谢各位啊 --------------------编程问答-------------------- 请问下你的登录代码是什么样的?能给我已经通过后的详细代码吗?
我的代码一直出错!实在不知道怎么解决!谢谢 --------------------编程问答-------------------- 为什么要在user那里加个[]呢
那是什么意思呀 --------------------编程问答-------------------- 可以用!最好给密码和用户名再加一下密! --------------------编程问答-------------------- 为什么要在user那里加个[]呢
==================================
user是SQL的关键字,加[]表示这是一个标识符
补充:.NET技术 , VB.NET