登录页面将无法正常工作! [英] LOGIN page wont work!!

查看:94
本文介绍了登录页面将无法正常工作!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我是该编程语言的新手..我目前在一个有3个输入的登录系统上工作;用户名,密码和位置
我的问题是,仅访问2个输入(用户名,密码)时,程序运行正常,但当访问3个输入时,发生了一些错误.
香港专业教育学院尝试过谷歌,和其他搜索引擎,但他们只为两个输入请帮助我.
这是我的代码

Hi im new in this programming language.. im currently working on a Log In system where there are 3 inputs; Username, Password and Position
my problem is when accessing only 2 inputs(Username, Password) the program works fine but when it is 3 some error occured.
Ive tried google, and other search engine but they are only for two inputs plss help me..
Here is my code

<pre lang="xml"><%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Web.UI" %>

<script language="VB" runat="server">

    Sub btnLogin_OnClick(Src As Object, E As EventArgs)
        Dim myConnection  As OleDbConnection
        Dim myCommand     As OleDbCommand
        Dim strUserURL    As String
        Dim strSQL        As String

        strSQL = "SELECT destination FROM tblLoginInfo " _
         & "WHERE username=''" & Replace(txtUsername.Text, "''", "''''") & "'' " _
         & "AND password=''" & Replace(txtPassword.Text, "''", "''''") & "'';" _
         & "AND position=''" & Replace(items.Text, "''", "''") & "'';"

        myConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " _
            & "Data Source=" & Server.MapPath("login.mdb") & ";")

        myCommand = New OleDbCommand(strSQL, myConnection)

        myConnection.Open()
        strUserURL = myCommand.ExecuteNonQuery()
        myConnection.Close()

        ''Response.Write(intUserCount)
        If strUserURL <> "" Then
            lblInvalid.Text = ""
            FormsAuthentication.SetAuthCookie(txtUsername.Text, True)
            Response.Redirect("bob.aspx")
        Else
            lblInvalid.Text = "Sorry... try again..."
        End If
    End Sub

</script>

<html>
<head>
<title>ASP.NET Login</title>
</head>
<body>

<h2>Please Login:</h2>

<p>
Hint:
</p>

<p>
<asp:Label id="lblInvalid" runat="server" />
</p>

<form runat="server">

    Username: <asp:TextBox id="txtUsername" runat="server" /><br />
    Password: <asp:TextBox id="txtPassword" TextMode="password" runat="server" /><br />
    <br />
    <br />
    <br />
    position: <asp:TextBox id="items" runat="server" /><br />
    <br />
    <br />
    <asp:Button id="btnLogin" runat="server"
        text="Login" OnClick="btnLogin_OnClick" Width="221px"
    />
</form>


<p>
If you''re not sure who you are currently logged in as you can
always check via the <a href="whoami.aspx">Who Am I?</a> page.
</p>

</body>
</html>




当我将其连接到本地主机时,这就是问题:




Here is the problem when i connect it to local host:

<pre lang="msil">IErrorInfo.GetDescription failed with E_FAIL(0x80004005).
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: IErrorInfo.GetDescription failed with E_FAIL(0x80004005).

Source Error:


Line 23:
Line 24:        myConnection.Open()
Line 25:         strUserURL = myCommand.ExecuteScalar()
Line 26:        myConnection.Close()
Line 27:


推荐答案

不确定这是否可以解决问题,但我看到了您的代码,发现您在第三行上有一个分号.我认为您应该将其删除.希望对您有所帮助.

Not sure if this can help but I saw your code and found out that you have a semicolon on the 3rd line. I think you should remove it. Hope it helps.

strSQL = "SELECT destination FROM tblLoginInfo " _
        & "WHERE username=''" & Replace(txtUsername.Text, "''", "''''") & "'' " _
        & "AND password=''" & Replace(txtPassword.Text, "''", "''''") & "'';" _
        & "AND position=''" & Replace(items.Text, "''", "''") & "'';"


这篇关于登录页面将无法正常工作!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆