Marcu

Marcu

  • NA
  • 5
  • 0

Getting error Incorrect syntax near '='

Sep 2 2008 1:13 PM

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:

 

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;

namespace HSI

{

public partial class login : System.Web.UI.Page

{

protected void Page_Load(object sender, System.EventArgs e)

{

 

 

}

 

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;

}

// Call Close when done reading.

reader.Close();

}

return bflag;

}

}

protected void Login1_Authenticate1(object sender, AuthenticateEventArgs e)

{

try

{

string uname = Login1.UserName.Trim(); //Get the username from the control

string password = Login1.Password.Trim(); //get the Password from the control

//changed

int userID;

bool 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.");

}

}

}


Answers (2)