Results 1 to 2 of 2

Thread: log in in vb.net?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    208

    log in in vb.net?

    i have the following table in my database.
    table name :logintbl
    type, username,password
    column type has to values only, either "admin" or "user"
    so that if username with type "admin" logged in then redirect to adminpage.aspx
    and if username with "user" type logged in, redirects to userpage.aspx
    the following code work fine for username and password authentication, so how do i modify to apply my above idea. thanks
    Code:
    con = New SqlConnection("server=(local); Data Source=gig;Initial Catalog=mydb;User ID=sa;Password=test")
            str = " select username,password from logintbl"
                    cmdadapter = New SqlDataAdapter(str, con)
            ds = New DataSet
            cmdadapter.Fill(ds, "logintbl")
            Try
                con.Open()
                For Each dr In ds.Tables(0).Rows
                    If (dr(0) = usernametxt.Text And dr(1) = passwordtxt.Text) Then
                        Session("userloggedin") = usernametxt.Text
                                            
                        Response.Redirect("addvacancy.aspx", False)
                        temp = True
                                                
                    Else
                        lbllogin.Text = " Sorry... try again,invalid username or password"
                        lbllogin.Font.Bold = True
                        lbllogin.ForeColor = Drawing.Color.Red
                           
                    End If
                    
                Next
            
            Catch ex As Exception
                con.Close()
            End Try

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: log in in vb.net?

    Add [type] to your SELECT query. If [type] = admin then admin page else user page

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width