1.关于access登录窗口代码
程序比较乱,说access登录窗口,但没有发现连接数据库的关键语句。很多不知道是控件还是其他,其实access登录窗口是特别简单的,只要使用文本框中的数据和数据库的数据进行对比即可。
给你代码参考:
Private Sub Command1_Click()
'登录确认
Dim sqldl As String
If Text1.Text = "" Or Text2.Text = "" Then
MsgBox "没有输入用户名或用户密码,请输入!", 16, "警告!"
Text1.SetFocus
Text2.Text = ""
Exit Sub
End If
db.ConnectionString = "DRIVER=Microsoft Access Driver (*.mdb);dbQ=" & App.Path & "\数据库名.mdb"
db.Open
strSQL = "select * from 登录表 where 名称='" & Text1.Text & "'"
RS.Open strSQL, db, 3, 3
If RS.EOF = True Then
MsgBox "没有这个用户,请重新输入用户名!", 16, "警告"
Text1.SetFocus
Text1.Text = ""
Text2.Text = ""
RS.Close
Set RS = Nothing
db.Close
Exit Sub
End If
If RS("密码") <> Text2.Text Then
MsgBox "密码不正确,请重新输入!", 16, "警告"
Text2.SetFocus
RS.Close
Set RS = Nothing
db.Close
Exit Sub
End If
RS.Close
Set RS = Nothing
db.Close
Unload Me
需要启动的窗体名.Show
End Sub
2.关于access登录窗口代码
程序比较乱,说access登录窗口,但没有发现连接数据库的关键语句。
很多不知道是控件还是其他,其实access登录窗口是特别简单的,只要使用文本框中的数据和数据库的数据进行对比即可。给你代码参考:Private Sub Command1_Click()'登录确认Dim sqldl As StringIf Text1.Text = "" Or Text2.Text = "" Then MsgBox "没有输入用户名或用户密码,请输入!", 16, "警告!" Text1.SetFocus Text2.Text = "" Exit SubEnd If db.ConnectionString = "DRIVER=Microsoft Access Driver (*.mdb);dbQ=" & App.Path & "\数据库名.mdb" db.Open strSQL = "select * from 登录表 where 名称='" & Text1.Text & "'" RS.Open strSQL, db, 3, 3If RS.EOF = True Then MsgBox "没有这个用户,请重新输入用户名!", 16, "警告" Text1.SetFocus Text1.Text = "" Text2.Text = "" RS.Close Set RS = Nothing db.Close Exit SubEnd IfIf RS("密码") <> Text2.Text Then MsgBox "密码不正确,请重新输入!", 16, "警告" Text2.SetFocus RS.Close Set RS = Nothing db.Close Exit SubEnd IfRS.CloseSet RS = Nothingdb.CloseUnload Me需要启动的窗体名.ShowEnd Sub。
3.请问asp+access登录后台的代码怎么写啊
Set rs = Server.CreateObject("Adodb.RecordSet") Sql = "Select * From admin where admin_name='"&p_adminname&"' And admin_pass='"&p_adminpass&"'" rs.Open Sql,Conn,1,3 If rs.Bof Then%> alert("无效的用户名或密码!"); location.href = "javascript:history.back()"; Else session("admin_name") = rs("admin_name") session("admin_bm") = rs("admin_bm") session("admin_lm")=rs("admin_lm") Response.redirect "admin_index.asp" rs.Close Set rs = Nothing End if End if%>。
4.请问用JSP+ACCESS做的会员登录与注册的代码怎么写
主要就是一个数据库操作的步骤,给你个简单的例子,1。
由登陆页面跳转过来后的处理<%@ page contentType="text/html;charset=gbk" language="java" import="java.sql.*"%><%@ include file="conn.jsp"%><% String username = request.getParameter("username"); String password = request.getParameter("password"); String sql ="select * from user where username='"+username+"' and password='"+password+"'"; try{ //PreparedStatement stmt = (PreparedStatement) conn.prepareStatement(url); Statement stmt=conn.createStatement(); ResultSet rs = stmt.executeQuery(sql); if(rs != null){ session.setAttribute("admin",username); out.print(""); out.close(); }else{ out.print(""); } }catch(Exception e){ System.out.println("数据库连接错误"); } /*finally{ if(rs != null) rs.close(); if(stmt != null) stmt.close(); if(conn != null){ conn.close(); }*/%>=======================conn.jsp代码<% String url = "jdbc:mysql://localhost/test?user=root&password=root&useUnicode=true&characterEncoding=gbk"; Class.forName("org.gjt.mm.mysql.Driver").newInstance(); Connection conn = (Connection) DriverManager.getConnection(url);%>。
5.vb登录窗体的代码怎么写,其中连接access数据库的语句是什么
Private Sub Command1_Click()
DataA.RecordSource = "select * from user where username='" + text1.Text + "'"
DataA.Refresh
If text1.Text = "" Or text2.Text = "" Then
MsgBox ""
text2.SetFocus
Else
If Trim(text1.Text) = DataA.Recordset.Fields(1) And Trim(text2.Text) = DataA.Recordset.Fields(2) Then
If text1.Text = "delta" Then
Form8.Show
Else
Form3.Show
End If
Form1.Hide
Else
MsgBox ""
text2.SetFocus
End If
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
DataA.DatabaseName = App.Path + "\db1.mdb"
DataA.RecordSource = "select * from user"
DataA.Refresh
End Sub
转载请注明出处育才学习网 » access登录代码怎么写