登录模块的后台代码有问题!请高手帮忙!不胜感激---

hengkongshi 2008-07-30 04:24:34
Imports System.IO
Imports System.Data
Imports System.Data.SqlClient
Imports System.Resources
Public Class login
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'判断是否为空
If ComboBox1.Text = "" Or TextBox1.Text = "" Then
MessageBox.Show("用户名或密码不能为空", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit Sub
End If
'数据库连接
Dim mycon As SqlConnection '声明连接对象
Dim Connectionstring As String = "server=localhost;database=mysql;uid=sa;pwd=123;" '连接字符串
mycon = New SqlConnection(Connectionstring) '创建连接
If mycon.State = ConnectionState.Closed Then
mycon.Open() '打开数据库
End If
Dim sqlstr As String = "select * from administrator where name = combobox1.text & password = textbox1.text"
Dim mycom As New SqlCommand(sqlstr, mycon)
Dim i As Integer = 0
If mycom.ExecuteScalar <> 1 Then
i = i + 1
If i > 3 Then
MsgBox("你已经3次输入错误密码!请下次再登录吧!")
Me.Button1.Enabled = False
Else
MessageBox.Show("密码错误!请重新输入!", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
TextBox1.Text = ""
ComboBox1.SelectedIndex = 0
Exit Sub
Else
'Me.管理员维护 toolstuipmenultem.enabled = True
'Me.添加管理员 toolstuipmenultem.enabled = True
'Me.增加读者信息 toolstuipmenultem.enabled = True
'Me.读者信息维护 toolstuipmenultem.enabled = True
'me.查看借阅历史 toolstuipmenultem.enabled = True
'me.书籍借阅管理 toolstuipmenultem.enabled = True
'Me.书籍信息查询 toolstuipmenultem.enabled = True
'me.书籍信息维护 toolstuipmenultem.enabled = True
'Me.读者信息查询 toolstuipmenultem.enabled = True
'Me.新增书籍管理 toolstuipmenultem.enabled = True
MessageBox.Show("恭喜你登陆成功!", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Application.Exit()
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim str1, str2 As String
str1 = vbCrLf & "关于用户" & vbCrLf
str2 = "系统默认用户名为:admin " & vbCrLf & "密码为:admin" & vbCrLf & "登录后请及时修改"
MsgBox(str1 & str2, MsgBoxStyle.OkOnly Or MsgBoxStyle.Information, "帮助信息")
End Sub
End Class
...全文
172 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
hengkongshi 2008-07-30
  • 打赏
  • 举报
回复
多谢上面大哥了。不过运行的时候 ComboBox1.SelectedIndex = 0 还会提示错误是怎么回事啊?还有就是数据源提示该项目没有关联的数据源---
ejoe313 2008-07-30
  • 打赏
  • 举报
回复

Dim sqlstr As String = "select * from administrator where name ='"& combobox1.text &"' and password = '"& textbox1.text &"'"

16,717

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧