The problem is still there
"incorrect syntax near the "="
is there really a syntax error ?
as far as i can see it got no syntax error .
CODE
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection myConn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\images\ChineseCheckerz.mdf;Integrated Security=True;User Instance=True");
try
{
myConn.Open();
string strQuery = "Select UserName , Password FROM UserInfo WHERE UserName =";
string WhereParameter = TextBox1.Text;
string.Format("{0}{1}", strQuery, WhereParameter);
SqlCommand myCommand = new SqlCommand(strQuery, myConn);
DataSet myDataSet = new DataSet();
SqlDataAdapter myAdapter = new SqlDataAdapter();
myAdapter.SelectCommand = myCommand;
myAdapter.Fill(myDataSet , "UserInfo");
// SqlDataReader myReader = myCommand.ExecuteReader();
/* if (myReader.HasRows)
{
MessageBox.Show("Has rows");
}*/
//while (myReader.Read())
for(int i = 0; i<=myDataSet.Tables["UserInfo"].Rows.Count - 1; i++)
{
UserName = Convert.ToString(myDataSet.Tables["UserInfo"].Rows[i]["UserName"]);
Password = Convert.ToString(myDataSet.Tables["UserInfo"].Rows[i]["Password"]);
}
//MessageBox.Show("UserName" + UserName);
// MessageBox.Show("Password" + Password);
//myReader.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if (myConn.State == ConnectionState.Open)
{
myConn.Close();
}
}
i comment out line by line and discovered that the problem lies with this line :
myAdapter.Fill(myDataSet , "UserInfo");
for the incorrect syntax near the "="
but i still think that its something to do with my strQuery as its being passed inside into the adapter when it runs mycommand.
This post has been edited by IceX: 12 May, 2008 - 12:40 AM