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

asp.net , db Adelaide, Australia
  • 12 years 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
     

  • 12 years 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?

     

  • 12 years ago

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

  • 12 years 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).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“There are only 3 numbers of interest to a computer scientist: 1, 0 and infinity”