Friday, March 16, 2012

Login Problem ::

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()I got it..
Thanks

"XD" <replymeonly@.hotmail.comwrote in message
news:eevzWezsGHA.4956@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

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()
>


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.

"XD" <replymeonly@.hotmail.comwrote in message
news:ujpSkX0sGHA.4140@.TK2MSFTNGP06.phx.gbl...

Quote:

Originally Posted by

>I got it..
Thanks
>
"XD" <replymeonly@.hotmail.comwrote in message
news:eevzWezsGHA.4956@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

>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()
>>


>
>

0 comments:

Post a Comment