locked
LoginForm Using Access Database RRS feed

  • Question

  • User1465679484 posted
    Hi there , Currently i m doing a project to using ASP.neT to create A interface for Mobile Phone PDA to access n the Login Shown below .. The userId and passwords are stored inside Access database . but some errors appear ...I m totally New to ASP .. n i been doing alot resreach on ASP for the past 4 weeks ...Can someone help ? thankz..


    Got this source from asp101 website

    Here Is the Source Code Login.aspx<%@ Page Language="vb" AutoEventWireup="false" Codebehind="Login.aspx.vb" Inherits="MobileWebApplication3.MobileWebForm3" %>
     <%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %><%@ Import Namespace="System.Data.OleDb" %>
    <script language=VB Runat="server"><!--EndFragment--> </BODY></HTML></script> <script  language="vb" runat="server">
    <%@ Page Language="vb" AutoEventWireup="false" Codebehind="Login.aspx.vb" Inherits="MobileWebApplication3.MobileWebForm3" %> <%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %><%@ Import Namespace="System.Data.OleDb" %>Funtion VaildateUser(uid As string,pwd As string)As Boolean

    Dim sFrist,sName as string
    Dim strConn as string="server=UrSrvr;uid=UrUid;pwd=UrPwd;database=UrDB"
    Dim MySQL as string="Select adminnumber,username,"&_"password from AdminPassword "&_"Where Login=@uid AND Password=@Pwd"
    Dim MyConn as New SQLCommand(MySQL,MyConn)

    cmd.Parameters.Add(New SQLParameter("@Uid",Uid))
    cmd.Parameters.Add(New SQLParameter("@Pwd",pwd))
    MyConn.Open()
    Try
    objDR=Cmd.ExecuteReader(System.data.CommandBehavior.CloseConnection)
     
    While objDR.Read()
    sUser=objDR("login")
    sPwd=objDR("Password")
    sName=objDR("Name")
    End While


    Dim SText as String 
       if sFrist=""and sLast="then blnValidUser="Fasle" 
             else blnValidUser="True" session("Name")=sName 
       End If


    Catch ex as Exception

                lblError.visible="true" 
                lblError.text="Sorry Errors Have occurred"

    Finally 
             ValidateUser=blnValidUser
              MyConn.Close()
    End Try
     End Funciton



    Sub doLogin(Source as Object,E as EventArgs)

    if ValidateUser(txtUID.text,txtPWD.text)=True Then 
          FormssAuthentication.RedirectFromLoginPage(txtUID.text, False)

    Else 
                lblError.Visible="True" 
                lblError.text="We're sorry,But the information you provided"&_" does not match our  database.Please try again."
           label1.text=""


    End If

    End Sub

    </script>


    User ID: <?xml:namespace prefix = asp /><asp:Textbox id=txtUID Runat="server"></asp:Textbox>
    Password: <asp:TextBox id=txtPWD Runat="server" TextMode="Password"></asp:TextBox>
    <asp:Button id=SubmitButton onclick=doLogin runat="server" Text="login"></asp:Button>



    In the Web.Config file

    <authentication mode="Forms">
                 <forms name=".FormName"
                              loginUrl="login.aspx" ' remember how we named the page for the form?
                             protection="All"
                            timeout="480"
                             path="/"
                     />
    </authentication>


    <authorization>
    <deny users ="?" />
    </authorization>


     

     

    Compilation Error

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: BC30456: 'doLogin' is not a member of 'ASP.Login_aspx'.

    Source Error:

    Line 89: 		
    Line 90: 				<td align="Right" valign="Top" Colspan="2">
    Line 91: 						<asp:Button id="SubmitButton"
    Line 92: 									Text="login"
    Line 93: 									onclick="doLogin"

    Source File: http://localhost/MobileWebApplication3/login.aspx    Line: 91




    Wednesday, August 17, 2005 4:24 AM

All replies

  • User-1029435529 posted
    Is that actually a cut and paste of your code? I ask because you have a number of spelling mistakes that will cause you problems.

    For example:
       Funtion VaildateUser(uid As string,pwd As string)As Boolean
          ' rest of your code
       End Funciton


    Should be:
       Function ValidateUser (uid As String, pwd As String) As Boolean
          ' rest of your code
       End
    Function

    The first thing you need to do then is correct your syntax errors. That may be enough to get your page working.
     
    Wednesday, August 17, 2005 6:00 AM
  • User1465679484 posted
    Ya i got it from website ..... thankz .... i got this error after i changed it ....
     

    Compilation Error

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: BC30203: Identifier expected.

    Source Error:

    Line 13: 	Dim sFrist,sName as string	
    Line 14: 	Dim strConn as string="server=UrSrvr;uid=UrUid;pwd=UrPwd;database=UrDB"
    Line 15: 	Dim MySQL as string="Select adminnumber,username,"&_"password from AdminPassword "&_"Where Login=@uid AND Password=@Pwd"
    Line 16: 	Dim MyConn as New SQLCommand(MySQL,MyConn)
    Line 17: 	cmd.Parameters.Add(New SQLParameter("@Uid",Uid))
    Wednesday, August 17, 2005 8:57 PM
  • User-1029435529 posted
    Again, you just have some syntax errors. In VB.NET (which is the language you are using), the characters & _ together mean "continued on the next line". Importantly, there is a space between the ampersand (&) and underscore (_).

    So, the original code was probably shown like this:
       Dim MySQL As String = "Select adminnumber,username," & _
             "password from AdminPassword " & _
             "Where Login=@uid AND Password=@Pwd"

    Because your code is not split across lines, you do not need the & _ characters. You can change your line of code to be:
       Dim MySQL As String = "Select adminnumber,username,password from AdminPassword Where Login=@uid AND Password=@Pwd"

    Note that the above line may wrap when viewed on your monitor. However, it needs to be a single line when you enter it into your code editor.
     
    Wednesday, August 17, 2005 10:29 PM
  • User1465679484 posted
    Thankz alot =) i will try it out
    Wednesday, August 24, 2005 9:09 PM
  • User1465679484 posted
    Hi ,is there a command that redirect the login page to other aspx page after  a successful login ?



    If Page.IsValid Then
        Dim UserDs As New System.Data.Dataset 
       userDs = GetUser(Username.Text,UserPass.Text)
    If userDS.TableS(0).Rows.Count =1 Then FormsAuthentication.RedirectFromLoginPage(UserName.Text, False)
     
    Response.Redirect("Page2.aspx"); <<<<<<< i try this but seem like it a wrong command....

    Any help will greatly appreacite
    Monday, August 29, 2005 12:05 AM
  • User1465679484 posted
    Got the problem slove .



    Anyone know what error is this ?


    No value given for one or more required parameters.

    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: No value given for one or more required parameters.

    Source Error:

    Line 60: 
    Line 61: 		conn.Open()
    Line 62: 		objDR=Cmd.ExecuteReader(system.data.CommandBehavior.CloseConnection)
    Line 63: 		MyDataGrid.DataSource=objDR
    Line 64: 		MyDataGrid.DataBind()

    The code is from here
    http://aspnet101.com/aspnet101/aspnet/codesample.aspx?code=editmdb

    Tuesday, August 30, 2005 9:53 PM
  • User-1804824805 posted

    Change:

    Dim MySQL As String = "Select adminnumber,username,password from AdminPassword Where Login=@uid AND Password=@Pwd"

    to:

    Dim MySQL As String = "Select adminnumber,username,[password] from AdminPassword Where Login=@uid AND [Password]=@Pwd"

    Password is a reserved word.

    Thursday, September 1, 2005 10:42 AM
  • User1465679484 posted
    thankz .
    Wednesday, September 7, 2005 12:08 AM