Community discussion forum

i am new in ASP.NET plz help me...!

  • 3 months ago

    i am new in ASP.NET....!

    and i want to create login page in ASP.NET...!

    i download a code from a tutorial website of ASP.NET

    but i have lots of problem when i modified the code...!

    <%@ Page Language="VB" %>
    <%@ import namespace="System.Data" %>
    <%@ import namespace="System.Data.OleDb" %>

    <script runat="server">

      Public Sub Login_Click(ByVal sender As Object, ByVal e As EventArgs)

        Dim userId As Integer
            Dim reader As OleDbDataReader
            'Dim connectionString = _
            'ConfigurationSettings.ConnectionStrings("MyConnectionString")
            'Dim conn As New SqlConnection(connectionString)
            'Dim command As New SqlCommand("dbo.Authenticate", conn)
           
           
            'my conncection
            Dim strConnection As String = "Provider=Microsoft.Jet.OleDb.4.0;" & _
                            "data source=E:\asadaspdotnet\nwind.mdb;"
            Dim objConnection As New OleDbConnection(strConnection)
            Dim command As New OleDbCommand("login.Authenticate", objConnection)


           
           

        ' Set the command type to stored procedure
        command.CommandType = CommandType.StoredProcedure

        ' Set @Username and @Password
            command.Parameters.Add("@Username", _
                    OleDbType.Char, 256).Value = Username.Text
            command.Parameters.Add("@Password", _
                OleDbType.Char, 256).Value = Password.Text

        ' Open the connection and execute the reader
            objConnection.Open()
           

    ' i have error at this point
            reader = command.ExecuteReader()

        ' Read the value we're looking for
        reader.Read()

        userId = Integer.Parse(reader("UserId"))

        ' Close connections
        reader.Close()
            objConnection.Close()

        ' Did we find a user?
        If (userId > 0) Then
            FormsAuthentication.RedirectFromLoginPage(Username.Text, _
                                                      False)
        Else
          Status.Text = "Invalid Credentials: Please try again"

        End If

      End Sub

    </script>

    <html>
      <body style="FONT-FAMILY: Verdana">

      <H1>Enter your username/password</H1>

      <form id="Form1" runat="server">
        Username: <asp:textbox id="Username" runat="server" />
        <br>
        Password: <asp:textbox id="Password" runat="server" />
        <p>
        <asp:button id="Button1"
                    text="Check if Member is Valid"
                    onclick="Login_Click" runat="server"/>
      </form>

      <font color="red" size="6">
        <asp:label id="Status" runat="server"/>
      </font>

      </body>
    </html>

    if u find any error then sove it
     

  • Advertisement

    Simply the fastest line-level profiler for .NET ever

    “The low overhead means it has minimal impact on the execution of my program”
    Mark Everest, Development Team Leader, Renault F1 Team Ltd.

    Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now

  • 3 months ago

    [quote user="asad_black"] reader = command.ExecuteReader()[/quote] 

    When you get to the line above, what is the exact error message that you get back?

     

  • 2 months ago

     i got error object " object name" is not stored in the procedure

  • 2 months ago

     Can you confirm that in your Access database nwind.mdb, you have a query called login.Authenticate?

Post a reply

Enter your message below

Sign in or Join us (it's free).