Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Login Problem ::

Reply
Thread Tools

Login Problem ::

 
 
XD
Guest
Posts: n/a
 
      07-29-2006
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()


 
Reply With Quote
 
 
 
 
XD
Guest
Posts: n/a
 
      07-29-2006
I got it..
Thanks

"XD" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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()
>



 
Reply With Quote
 
 
 
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      07-30-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I got it..
> Thanks
>
> "XD" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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()
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
News login different from mail login William W. Plummer Firefox 21 04-08-2005 05:37 AM
Strange problem with Forms authentication: After successfull login, login page is still displayed Pascal Blanchard ASP .Net Security 1 08-18-2004 08:36 AM
Strange problem with Forms authentication: After successfull login, login page is still displayed Pascal Blanchard ASP .Net Security 0 08-17-2004 06:26 PM
Forms Login Page Not Login Out Hermit Dave ASP .Net 5 01-13-2004 07:14 AM
Re: PLEASE? Any way to get the user's nt login from the pc -- not the server login? William F. Robertson, Jr. ASP .Net 0 07-02-2003 03:57 PM



Advertisments