asp.net中的查询字符串中出现编译错误
这些行中出现错误,请帮助我尝试以下操作:asp.net中的查询字符串中出现编译错误,asp.net,string,Asp.net,String,这些行中出现错误,请帮助我尝试以下操作: SqlConnection cn = new SqlConnection("server=localhost;initial catalog=newmits;trusted_connection=true"); cn.Open(); string q = string.Format("SELECT * from upnotice WHERE notice_type LIKE '{0}%'",t); SqlDataAdapter adp = new S
SqlConnection cn = new SqlConnection("server=localhost;initial catalog=newmits;trusted_connection=true");
cn.Open();
string q = string.Format("SELECT * from upnotice WHERE notice_type LIKE '{0}%'",t);
SqlDataAdapter adp = new SqlDataAdapter(q,cn);
DataSet ds = new DataSet();
adp.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
这个错误到底发生在哪里?错误到底是什么?请提供完整准确的错误信息!编译错误发生在这些行中,字符串q=string.FormatSELECT*from upnotice,其中notice_类型类似于“{0}%”,t;编译器错误消息:CS0103:名称“t”在当前上下文中不存在sir我想从我的数据库中获取通知类型为Tender&RecruementNotice的数据sir再次出现编译错误Ankx sir现在工作了sir您能解释为什么出现错误吗您必须将其定义为字符串:。。。注意像“{0}%”这样的类型,t;定义t。字符串t;
string q = "SELECT * from upnotice WHERE notice_type like '%Tender%' OR notice_type like '%RecruitementNotice%'";