المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : syntax error...plz help me



C# Programming
08-26-2009, 04:23 PM
Server Error in '/WebSite1' Application.
--------------------------------------------------------------------------------

Syntax error (missing operator) in query expression 'DOCTOR NAME = 'ankit''.
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.Data.OleDb.OleDbException: Syntax error (missing operator) in query expression 'DOCTOR NAME = 'ankit''.

Source Error:


Line 175: OleDbCommand cmd4 = new OleDbCommand(query,con1);
Line 176: //cmd4.ExecuteNonQuery
Line 177: dr = cmd4.ExecuteReader();
Line 178: if (dr.Read())
Line 179: {


Source File: c:\Users\Ankit\Documents\Visual Studio 2005\WebSites\WebSite1\Default2.aspx.cs Line: 177

my code is

tring connection1 = ConfigurationManager.AppSettings["conn"];
OleDbConnection con1 = new OleDbConnection(connection1);
con1.Open();
OleDbDataAdapter da = new OleDbDataAdapter();
DataSet ds = new DataSet();


OleDbDataReader dr;
string query="select COUNT(*) from appointment where DOCTOR NAME = '" + DropDownList1.SelectedItem + "' ";

OleDbCommand cmd4 = new OleDbCommand(query,con1);
//cmd4.ExecuteNonQuery
dr = cmd4.ExecuteReader();
if (dr.Read())
{
//if (Convert.ToInt16(dr[0]) != 4)
TextBox3.Text = "hello";
TextBox3.Text = dr[0].ToString();
}