Control Panel
Forum
Hosting Help
6 Months free Hosting (New!)
Resources
Login
Members
Shared Hosting
|
New Features
|
Advertise
|
Tutorials
|
Product Reviews in India
|
Free aptitude test questions
|
TATA Nano Car reviews
Total
members
:
82075
Average new registrations per day (in last 7 days):
44
New Registration:
Open
Register Now
Home
»
Questions & Answers
»
vb.net doubt
vb.net doubt
6/11/2008
Author:
gandhi1947
Dim conn As SqlConnection
conn = New SqlConnection("Initial Catalog=aaa;Server=asteroid;UID=sa;PWD=sa;")
Dim cmd As SqlCommand
cmd = New SqlCommand("select username,password from users where username='textbox1' and password='textbox2'", conn)
Dim reader As SqlDataReader
conn.Open()
reader = cmd.ExecuteReader()
If (reader.Read()) Then
txtusername.Text = reader("studentname")
txtpassword.Text = reader("studentid")
Else
Label3.Text = "Enter correct name and id"
End If
conn.Close()
the above codeing working fine. but i have some doubt.
1. if i enter correct or wrong username and password then click "ok" button displayed "enter correct name and id"
my expectation is if i enter correct username and password then click "ok" it will go to response.redirect("default2.aspx")
if i enter wrong username password then click ok button that time i will get "enter correct name and id" how to do it?
Answers .............
Author:
Hemanta Kumar Pradhan
InteZign Solution
Posted Date: 7/7/2008
just add a flag (boolean) and on basis of flag redirect the page.
Dim conn As SqlConnection
conn = New SqlConnection("Initial Catalog=aaa;Server=asteroid;UID=sa;PWD=sa;")
Dim isAuthenticated as boolean
Dim cmd As SqlCommand
cmd = New SqlCommand("select username,password from users where username='textbox1' and password='textbox2'", conn)
Dim reader As SqlDataReader
conn.Open()
reader = cmd.ExecuteReader()
If (reader.Read()) Then
txtusername.Text = reader("studentname")
txtpassword.Text = reader("studentid")
isAuthenticated = true
Else
Label3.Text = "Enter correct name and id"
isAuthenticated = false
End If
conn.Close()
If (isAuthenticated) Then
Response.redirect("")
EndIF
You must
login
to post answer for this question.
Partners
Privacy Policy
Terms of use
Contact Us
SpiderWorks Technologies.
All Rights Reserved.