二楼说的是asp.net,因你发在这个板块,不详细看题的很容易认为用.net实现 这种问题建议自己先看下相关的书籍,有疑问再提出实现代码如下,安全问题自己完善下: dim connStr, conn, rs, sql connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("你的数据库路径") set conn=server.createobject("adodb.connection") conn.Open connStr If Err Then err.Clear Set conn= Nothing Response.Write "数据库连接出错,请检查连接字串。" Response.End End Ifsql = "Select * From [用户表名] where 用户名='***' and 密码='***'" rs=conn.ExeCute(sql) if not rs.eof then session("用户名")=rs("用户名") response.write("<script>alert('用户登陆成功')</script>") else response.write("<script>alert('错误的用户名或密码')</script>") end if
Conn.Open "Provider=Microsoft.Jet.Oledb.4.0;Data Source="&Server.MapPath("../Data#Base/Data#Base.mdb")
http://www.doc88.com/p-78740354103.html
OleDbCommand cmd=new OleDbCommand("select count(*) from 用户 where 用户名=@name and 密码=@password",cn);
cmd.Parameters.AddWithValue("@name",TextBoxUserName.Text);
cmd.Parameters.AddWithValue("@password",TextBoxPassWord.Text);
cn.Open();
if((int)cmd.ExecuteScalar()==1)
//提示成功;
else
//提示失败;
cn.Close();
这种问题建议自己先看下相关的书籍,有疑问再提出实现代码如下,安全问题自己完善下:
dim connStr, conn, rs, sql
connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("你的数据库路径")
set conn=server.createobject("adodb.connection")
conn.Open connStr
If Err Then
err.Clear
Set conn= Nothing
Response.Write "数据库连接出错,请检查连接字串。"
Response.End
End Ifsql = "Select * From [用户表名] where 用户名='***' and 密码='***'"
rs=conn.ExeCute(sql)
if not rs.eof then
session("用户名")=rs("用户名")
response.write("<script>alert('用户登陆成功')</script>")
else
response.write("<script>alert('错误的用户名或密码')</script>")
end if
conn.close:set conn=nothing
Oledbconnection(要引用命令空间) conn=new Oledbconnection();
conn.Connectionstring="Provider=Microsoft.Jet.Oledb.4.0;Data Source="HttpContext.Current.Server.MapPath("~/App_Data/#antemarital.mdb") + ;
conn.open();