Login Problem ::

X

XD

It is nor redirecting to default.aspx...What I am doing wrong??


Dim StrUser As String, StrPass As String
Dim BValid As Boolean
Dim Conn As Data.SqlClient.SqlConnection
Dim strCommand As Data.SqlClient.SqlCommand
Dim strReader As Data.SqlClient.SqlDataReader
Dim StrSQL As String

StrUser = txtUser.Text
StrPass = txtPass.Text

BValid = False

Conn = New Data.SqlClient.SqlConnection("Data Source=xxxx; Initial
Catalog=xxxx; User ID=xxx; Password=xxxx")

StrSQL = "SELECT * FROM Users WHERE UserName='" & StrUser & "' and
password='" & StrPass & "'"
strCommand = New Data.SqlClient.SqlCommand(StrSQL, Conn)
Conn.Open()

Response.Write(StrSQL)


strReader = strCommand.ExecuteReader()

While strReader.Read()
If strReader("UserName") <> "" And strReader("Password") <> ""
Then
'Response.Cookies("ValidUser").Value = strReader("UserName")
'Response.Cookies("ValidUser").Expires =
DateTime.Now.AddMonths(1)
BValid = True
Else
BValid = False
End If
End While


If BValid = True Then
Response.Redirect("default.aspx")
ElseIf BValid = False Then
LblError.Text = "Login Error: Please try again."
End If

Conn.Close()
 
K

Ken Cox [Microsoft MVP]

That's good, but it's polite to explain the fix in case someone else with
the same problem does a search on the issue.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top