|
-
Mar 17th, 2009, 07:17 AM
#1
Thread Starter
Addicted Member
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
-
Mar 17th, 2009, 01:26 PM
#2
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|