62,025
社区成员
发帖
与我相关
我的任务
分享
<%@ Page Title="主页" Language="vb" MasterPageFile="~/Site.Master" codebehind="Default.aspx.vb" AutoEventWireup="false" Debug="true"
%>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<!--#include virtual="login.aspx"-->
<style type="text/css">
.style4
{
height: 27px;
}
.style22
{
width: 222px;
height: 67px;
}
.style23
{
width: 222px;
height: 73px;
}
.style26
{
width: 166px;
height: 67px;
}
.style27
{
height: 73px;
width: 166px;
}
.style28
{
width: 75px;
height: 67px;
}
.style29
{
width: 75px;
height: 73px;
}
.style30
{
width: 129px;
height: 67px;
}
.style31
{
height: 73px;
width: 129px;
}
</style>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<script runat="server" language="vb">
Sub smlogin(ByVal obj As Object, ByVal e As EventArgs)
If Application("dubug") = 1 Then
' Response.Write("smlogin过程已执行" & "<br>")
Label1.Text += "smlogin过程已执行" & "<br>"
End If
Dim userid As Integer = Login(tbuser.Text,tbpass.Text)
' Response.Write(userid)
If Application("dubug") = 1 Then
Label1.Text += userid.ToString
Literal1.Text += "Username:" & tbuser.Text & "<spacer " & _
"type='horizontal' size=143> " & "Password:" & _
tbpass.Text & " <br> "
End If
If userid <> 0 Then
Session("userid") = userid
Response.Redirect("Account.aspx")
End If
End Sub
</script>
<table class="" border="1" style="width: 918px">
<tr>
<td class="style22">
<div style="position:relative;left:40px; top:-23px; width:auto">
<asp:Literal ID="Literal1" runat="server"></asp:Literal>
</div>
</td>
<td class="style30">
</td>
<td class="style28">
</td>
<td class="style26">
<!----------- 登录表单 ------------------>
<table height="100%" border="0" width="100%">
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="用户:" ForeColor="Black"/>
</td>
<td>
<asp:TextBox ID="tbuser" runat="server"></asp:TextBox></td>
<td>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lbpass" runat="server" Text="密码:" ForeColor="Black"/>
</td>
<td>
<asp:TextBox ID="tbpass" runat="server"></asp:TextBox></td>
<td>
</td>
</tr>
<tr>
<td class="style4">
</td>
<td class="style4">
<asp:Button ID="btlogin" runat="server" Text="登录" onclick="smlogin" />
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="register.aspx">注册</asp:HyperLink>
</td>
<td class="style4">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="style23">
</td>
<td class="style31">
</td>
<td class="style29">
</td>
<td class="style27">
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
</td>
</tr>
</table>
<div style="position:absolute;
height: 81px; width: 551px;left:396px;">
<div style="position:relative;left:10px;top:10px;width:auto">
</div>
</div>
<br />
1 1
<h2>
欢迎使用 ASP.NET!
</h2>
若要了解关于 ASP.NET 的详细信息,请访问 <a href="http://www.asp.net/cn" title="ASP.NET 网站">www.asp.net/cn</a>。
<p>
您还可以找到 <a href="http://go.microsoft.com/fwlink/?LinkID=152368"
title="MSDN ASP.NET 文档">MSDN 上有关 ASP.NET 的文档</a>。
</p>
<p>
</p>
</asp:Content>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script runat="server" language="vb">
Public Sub Page_Load(ByVal obj As Object, ByVal e As EventArgs) Handles Me.Load
' Response.Write("p用户名不能为空!")
End Sub
Function Login(ByVal user As String, ByVal pass As String) As Integer
If Application("dubug") = 1 Then
Label1.Text += "Login过程执行" & "<br>"
' Response.Write("Login过程执行")
Label1.Text +="Username:" & user & " " & "Password:" & pass
'Literal1.Text += "Username:" & tbuser.Text & "<spacer " & _
' "type='horizontal' size=143> " & "Password:" & _
' tbpass.Text & " <br> "
End If
<%-- ------------ 数据连接驱动备用选择 --------------------- --%>
<%--
("provider=Microsoft.ace.OLEDB.12.0;Data Source=" & Server.MapPath("user.accdb"))
("provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("user_m.mdb"))
--%>
<%-- ------------ 开始连接数据库 -------------- --%>
Dim objConn As OleDbConnection = New OleDbConnection("provider=Microsoft.ace.OLEDB.12.0;Data Source=" & Server.MapPath("user_m.mdb"))
objConn.Open()
Dim objCmd As New OleDbCommand("select userid from users where username=@user and password=@pass", objConn)
Dim objparam As OleDbParameter
objparam = New OleDbParameter("@user", OleDbType.Char)
objparam.Value = user
objParam.direction = parameterdirection.input
objCmd.Parameters.Add(objparam)
objparam = New OleDbParameter("@pass", OleDbType.Char)
objparam.Value = pass
objParam.direction = parameterdirection.input
objCmd.Parameters.Add(objparam)
Dim userID As Integer = CType(objCmd.ExecuteScalar, Integer)
objConn.Close()
Return userID
End Function
</script>