id是数据库的id,但是你在使用这条sql语句之前,需要定义这个id啊 比如 string id=3; 然后就是你的 SqlDataAdapter da = new SqlDataAdapter("select * from one where id="+id, con);
int Id=1; SqlDataAdapter da = new SqlDataAdapter("select * from one where id="+id, con);
比如说应该有个方法吧 例如: public Ilist<product> GetproductById(int id){ SqlDataAdapter da = new SqlDataAdapter("select * from one where id="+id, con); } 后面得Id事在方法里面来得知道了吗 ???
你要给这个ID赋值才行啊。 随便定义一个int id=1 或 int id= Convert.ToInt32(Request["id"]);//取值
都说得不错,我就不多分析了,LZ头像MM不错,5楼的用户名很猛
第一,你后面的那个变量ID 没有定义, 第二,变量ID和你的数据库里的ID不能一样,
对 后面id需要在当前页面定义 前面where紧跟的id是数据库查询条件id 是数据库字段
SqlDataAdapter da = new SqlDataAdapter("select * from one where id="+id, con); 呵呵,当然得定义一个参数呀,有参数类的,而且ID为INT型,语句不能那样写的,加不起来
问题: SqlDataAdapter da = new SqlDataAdapter("select * from one where id="+id, con); 我就是搞不懂 第二个id错误,(提示说上下文不存在名称id)这个id是 数据库里id啊,为什么提示错误呢?解答: 第二个id你没有定义,故在运行时提示错误信息。再者;补充下再连接id时也可以用”&“来连接,不容易混淆有时“+”当加号使用,有时当连接符使用。所以在写此类题目代码时,建议用“&"比较好!呵呵……(当然只是建议啦)
比如
string id=3;
然后就是你的
SqlDataAdapter da = new SqlDataAdapter("select * from one where id="+id, con);
SqlDataAdapter da = new SqlDataAdapter("select * from one where id="+id, con);
public Ilist<product> GetproductById(int id){
SqlDataAdapter da = new SqlDataAdapter("select * from one where id="+id, con);
}
后面得Id事在方法里面来得知道了吗 ???
随便定义一个int id=1
或
int id= Convert.ToInt32(Request["id"]);//取值
第二,变量ID和你的数据库里的ID不能一样,
SqlDataAdapter da = new SqlDataAdapter("select * from one where id="+id, con);
我就是搞不懂 第二个id错误,(提示说上下文不存在名称id)这个id是 数据库里id啊,为什么提示错误呢?解答:
第二个id你没有定义,故在运行时提示错误信息。再者;补充下再连接id时也可以用”&“来连接,不容易混淆有时“+”当加号使用,有时当连接符使用。所以在写此类题目代码时,建议用“&"比较好!呵呵……(当然只是建议啦)