在查询中加入条件的语句怎么写?(条件是变量)
string strSQL =
"SELECT * FROM Customer where City"+Label1.Text.ToString();
用这句话查询总是出错,请问到底是为什么
private void Button1_Click(object sender, System.EventArgs e)
{
Label2.Text ="Your Select City Is "+CityName.SelectedItem.Text;
string strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\\Inetpub\\wwwroot\\aspbbs\\data\\xtreme.mdb";
string strSQL ="SELECT * FROM Customer where City="+CityName.SelectedItem.Text.ToString();
OleDbConnection myConn = new OleDbConnection(strDSN);
OleDbCommand myCmd = new OleDbCommand(strSQL,myConn);
myCmd.Connection.Open();
DataGrid1.DataSource=myCmd.ExecuteReader();
DataGrid1.DataBind();
}