经典 ASP & Access DB - FROM 子句错误

Classic ASP & Access DB - FROM Clause Error

这是我第一次 post 在这里,希望大家能理解我的英语,我正在尝试在基于 MS Access 的 VBScript(经典 ASP)中创建一个站点,使用CSS 和一些 Ajax/Jquery.

我到了管理登录和会话的地步,所以在主页中创建了一个弹出表单并将数据提交到另一个 asp 页面以验证用户并最终打开一个会话,只是一个这个问题:FROM 子句有错误,我实际上在数据库上尝试了相同的查询,它确实有效!

出于演示目的,我的大部分代码都是意大利语: "nome" = 姓名,"cognome" = 姓氏,"DataNascita" = 生日,"amministratore" = 管理员。

至于数据库,名称从 table 到 table 是不同的,因为我试图编写不同名称的外键以排除每个选项。

HTML 表格代码:

<form Action="authenticate.asp" Method="Post">
                    <div class="row">
                        <div class="cells"> 
                            <span> Username </span> 
                        </div>
                        <div class="celld">
                            <Input Type="Text" Name="TxtUsername" Placeholder="Username"> 
                        </div>
                    </div>
                    <div class="row">
                        <div class="cells"> 
                            <span> Password </span>
                        </div>
                        <div class="celld">
                            <Input Type="Password" Name="TxtPassword" Placeholder="Password">  
                        </div>
                    </div>
                    <div class="row">
                        <div class="cellrowspan"> 
                            <Input Type="Submit" Value="Login"> 
                        </div>
                    </div>
                </form>

无法 POST 图像,这就是我的数据库的结构

Table (Account) - AccountID (Pk) [Auto.Inc], Username [String], Password [String]

Table (User) - UserID (Pk) [Auto.Inc], ProfiloID (Fk. of Account) [Long Integer], Nome [String], Cognome [String], Data_Nascita [Data], E_Mail [String], LivelloID (Fk. of Livello) [Long Integer].

Table (Livello) - PrivilegioID (Pk) [Auto.Inc], Categoria [String]

最后 authenticate.asp 页面响应表单

<%
Dim Username, Password, Nome, Cognome, DataNascita, Email, IDLevel, StrConn, Conn, Rs
    Username = Trim(Request.Form("TxtUsername"))
    Password = Trim(Request.Form("TxtPassword"))

    IF Username <> "" AND Password <> "" THEN
        StrConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Server.MapPath("Users.accdb")

        Set Conn = Server.CreateObject("ADODB.Connection")
        Set Rs = Server.CreateObject("ADODB.Recordset")

        Conn.Open StrConn
        Set Rs = Conn.Execute ("SELECT User.Nome, User.Cognome, User.Data_Nascita, User.E_Mail, User.LivelloID FROM (Account INNER JOIN User ON Account.AccountID=User.ProfiloID) INNER JOIN Livello ON User.LivelloID=Livello.PrivilegioID WHERE Account.Username='" & Username & "' AND Account.Password='" & Password & "'")
            Nome = Rs.Fields("Nome")
            Cognome = Rs.Fields("Cognome")
            DataNascita = Rs.Fields("Data_Nascita")
            Email = Rs.Fields("E_Mail")
            IDLevel = Rs.Fields("LivelloID")

        Rs.Close
        Conn.Close
        Set Rs = Nothing
        Set Conn = Nothing

        Session("NomeUtente") = Nome
        Session("CognomeUtente") = Cognome
        Session("DataNascita") = DataNascita
        Session("Email") = Email
        Session("Authenticated") = 1
        IF IDLevel = 1 THEN 
            Session("Amministratore") = "True"
        ELSE 
            Session("Amministratore") = "False"
        END IF
    END IF

Response.Redirect ("homepage.asp")
%>

您使用了很多访问字段名的保留字。如果你在访问系统运行的同时进行查询,但是如果你使用asp传递查询会出错。您应该更改 tables 字段的名称。

Es.: table "user" 变成了 "utenti", 等等...