Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
If txt1.Text = "" Then
MsgBox("用户名不能为空! 请先输入用户名后再登陆")
txt1.Focus()
Else
Dim cnn As New OleDb.OleDbConnection
cnn.ConnectionString = "provider=Microsoft.Jet.oledb.4.0;Data source=I:\Software\software\software\Database1.mdb"
cnn.Open()
Dim ds As New DataSet
Dim da As New OleDb.OleDbDataAdapter("select * form [user]", cnn)
cnn.Close()
da.Fill(ds, "user")
If ds.Tables(0).Rows.Count <> 0 Then
Dim sql As String = "select * form [user] where username=" & Trim(txt1.Text) & ""
Dim da1 As New OleDb.OleDbDataAdapter(sql, cnn)
Dim ds1 As New DataSet
da1.Fill(ds1, "user")
If ds1.Tables(0).Rows.Count = 0 Then
MsgBox("用户名错误!")
txt1.Text = ""
txt1.Focus()
Else
If txt2.Text = "" Then
MsgBox("请输入密码!")
txt2.Focus()
Else
Dim sq2 As String = "select password from user where username=" & Trim(txt1.Text) & " and password=" & Trim(txt2.Text) & ""
Dim da2 As New OleDb.OleDbDataAdapter(sql, cnn)
Dim ds2 As New DataSet
da2.Fill(ds2, "user")
If ds2.Tables(0).Rows.Count = 0 Then
MsgBox("密码错误!请重新输入密码!")
txt2.Text = ""
txt2.Focus()
Else
Me.Hide()
detail.ShowDialog()
End If
详细解决方案
用VB.net链接access数据库做登陆界面,网上的一段代码,运行有异常,求解答
热度:54 发布时间:2016-04-25 02:11:44.0
相关解决方案
- java.sql.SQLException: Access denied for user 'root'@'localhost' (using password,该如何处理
- java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] 找不到资料 '(未知的)'
- java.sql.SQLException: Access denied for user 'root'@'localhost' (using password解决思路
- jsp access 图片调用的有关问题
- 小弟我用JSP+ACCESS+tomcat 5.0 JDK1.4做的一个网站
- 出现异常:cvs [server aborted]:"passwd" requires write access to the repository
- java.lang.SecurityException: Application not authorized to access the restricted API有关问题,
- java and access,该如何解决
- java.security.AccessControlException: access denied (java.lang.
- java.security.AccessControlContext.checkPermission:access denied
- 何为原子访问(atomic access)解决方案
- 作甚原子访问(atomic access)
- 继续:vs2005 vc access 取不到表中的数据,该如何解决
- 持续:vs2005 vc access 取不到表中的数据
- vs2005,vc access MoveNext()
- dax error : access violation at address解决办法
- Delphi程序写的EXCEL导入程序时报错:Access violation at address0057416f in module"serv"exe,该怎么解决
- dax error : access violation at address,该如何解决
- Mapabc老是报错“Access Denied,Status=4,Host=AN_Tianjin_28_100”,高分求指教
- Access to report file denied. Another program may be using it.(水晶报表导出PDF时的异常)
- asp.net+access,批量替换access内容解决方案
- access 后盾更新
- access like 内存储器溢出
- asp.net+access,批量轮换access内容
- Access Update 替select值出错 操作必须使用一个可更新的语句
- cannot access private field 'key' here解决办法
- ACCESS 怎的获得刚插入数据的ID
- asp.net access update 语句 语法异常 质疑
- access 查询语句的有关问题
- 网站间接性出现空缺 整站没有数据,是什么原因啊(net+access)