Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Trouble with a simple login( figured it out myself

Author  Topic 

asmarl
Starting Member

3 Posts

Posted - 2009-12-16 : 08:55:15
I have an assignment due and I am having problems with my login. I am rather new at this so when debug and get errors I dont always know what to do with it below is my code and errors thanks in advance for helping me out





Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
If (IsPostBack()) Then

If txtUserName2.Text = "" Or txtPass3.Text = "" Then
lblErr.Visible = True
'Response.Redirect("default.aspx")
End If


Try
objConnection = New OleDbConnection(connString)
objConnection.Open()

strSQL = "SELECT USER_NAME, PASSWD from UZER WHERE USER_NAME = '" & txtUserName2.Text & "' AND PASSWD = '" & txtPass3.Text & "'"
Response.Write(strSQL)


objCommand = New OleDbCommand(strSQL, objConnection)
objDataReader = objCommand.ExecuteReader(CommandBehavior.CloseConnection)

objConnection.Close()
Catch ex As Exception
Response.Write("<br >")
Response.Write(ex)
Response.Write(strSQL)
End Try

If objDataReader("USER_NAME") = txtUserName2.Text And objDataReader("PASSWD") = txtPass3.Text Then
Response.Cookies("userInfo")("UserName") = txtUserName2.Text

Response.Redirect("Home.aspx")

End If

End If

End Sub






End Class


<table style="width: 100%;" bgcolor="White">
<tr>
<td class="style2" colspan="2">
<asp:Label ID="Label4" runat="server" Text="Login" Font-Size="Large"></asp:Label>
 
<asp:Label ID="lblErr" runat="server" Text="User Name And Password Must Be Entered" Font-Size="Smaller" ForeColor="Red"></asp:Label>
</td>
</tr>
<tr>
<td class="style4">
<asp:Label ID="Label3" runat="server" Text="User Name"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtUserName2" runat="server" TabIndex="1"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style4">
<asp:Label ID="Label2" runat="server" Text="Password"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtPass3" runat="server" TabIndex="2"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style4">
 </td>
<td>
<asp:Button ID="btnLogin" runat="server" Text="Login" style="height: 26px" TabIndex="3" />
</td>
</tr>
</table>



ERROR
No data exists for the row/column.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: No data exists for the row/column.

Source Error:

Line 130: End Try
Line 131:
Line 132: If objDataReader("USER_NAME") = txtUserName2.Text And objDataReader("PASSWD") = txtPass3.Text Then
Line 133: Response.Cookies("userInfo")("UserName") = txtUserName2.Text
Line 134:


Source File: K:\asmarl\itwp2300\NetFamily\Default.aspx.vb Line: 132


thanks for looking but I have figured it out!
Lori

asmarl
Starting Member

3 Posts

Posted - 2009-12-16 : 09:35:08
Oh also I there is information in the database and all fields are correct as far as the naming goes.
thanks
Lori
Go to Top of Page
   

- Advertisement -