I receive this error after the
SQLDataReader reader = command.ExecuteReader();
line during debugging. I have tried to figure out where this is at but have been unable to locate it. Can someone look at the end and determine where the error is. Here is my code:
PowerShell
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;Code
{
public partial class login : System.Web.UI.Page
{{
}
private bool AuthenticateUser(string uname, string password, out int userID)
{
userID = -1;
bool bflag = false;string queryString = "Server=hsisql;Database=hsi;Integrated Security=True";
string strSQL = "select * from icc_users where username ='" + uname + "' AND password ='" + password + "'";
using (SqlConnection connection = new SqlConnection(queryString))
{
SqlCommand command = new SqlCommand(queryString, connection);connection.Open();
SqlDataReader reader = command.ExecuteReader();{
// Call Read before accessing data.
if (reader.Read()){
userID = System.Convert.ToInt32(reader[0]);bflag = true;Code
}
// Call Close when done reading.
reader.Close();
}}
}
protected void Login1_Authenticate1(object sender, AuthenticateEventArgs e)C#
{
try
{
string uname = Login1.UserName.Trim(); //Get the username from the control
string password = Login1.Password.Trim(); //get the Password from the control
//changedbool flag = AuthenticateUser(uname, password, out userID);
if (flag == true){
e.Authenticated = true;//Changed
HttpContext.Current.Session["userID"] = userID;Login1.DestinationPageUrl = "reports.aspx";
}
else
e.Authenticated = false;}
catch (System.Exception){
e.Authenticated = false;}
}
private bool AuthenticateUser(string uname, string password){
throw new System.Exception("The method or operation is not implemented.");Code
}
}
}
Bechir BejaouiRank #144 · 15.9K pointsPosted Sep 6, 2008, 1:53 AM EDT
Bechir BejaouiRank #144 · 15.9K pointsPosted Sep 6, 2008, 1:53 AM EDT