asp 这段代码 在gv中一直得不到oracle的表中数据
protected void Button2_Click(object sender, EventArgs e){
string mConn = "Provider=MSDAORA; Data Source=XE;" + "Persist Security Info=True; User ID=system;Password=manger";
OleDbConnection conn = new OleDbConnection(mConn);
conn.Open();
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = conn;
string cn = this.DropDownList1.Text.ToString();
string pn = this.DropDownList2.Text.ToString();
string nn = this.DropDownList3.Text.ToString();
OleDbCommand it = new OleDbCommand("select id,citycode,productcode,noticecode,money,statename from t_state,t_city,t_product,t_notice,tong_zhi where citycode=(select citycode from t_city where cityname='"+cn+"') and productcode=(select productcode from t_product where productname ='"+pn+"')and noticecode=(select noticecode from t_notice where noticename='"+nn+"')and tong_zhi.statecode1 = t_state.statecode and tong_zhi.citycode1 = t_city.citycode and tong_zhi.productcode1=t_product.productcode and tong_zhi.noticecode1 = t_notice.noticecode order by id ", conn);
OleDbDataAdapter da = new OleDbDataAdapter(it);
DataSet ds = new DataSet();
da.Fill(ds);
this.GridView1.DataSource = ds.Tables[0].DefaultView;
this.GridView1.DataBind();
//关闭数据库连接
conn.Close();
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
oracle asp --------------------编程问答-------------------- 有没有大神知道啊 急 --------------------编程问答-------------------- 你的查询语句有问题,难道没有抛出异常吗?
select id,citycode,productcode,noticecode,money,statename
from t_state,t_city,t_product,t_notice,tong_zhi
where citycode=(select citycode from t_city where cityname='"+cn+"')
where 后面括号的子查询如果有多个值就会报错,等号应该改为IN
即:
select id,citycode,productcode,noticecode,money,statename
from t_state,t_city,t_product,t_notice,tong_zhi
where citycode IN (select citycode from t_city where cityname='"+cn+"')
还有后面的代码就自己改了 --------------------编程问答-------------------- 我之前用过IN 还是没有用 我将cityname直接赋值了 却可以出来了 --------------------编程问答--------------------
我之前用过IN 还是没有用 我将cityname直接赋值了 却可以出来了
--------------------编程问答-------------------- ...还是没有弄好啊
--------------------编程问答-------------------- 注意其中的空格如: ) and
另你把 "select id,citycode,productcode,noticecode,money,statename from t_state,t_city,t_product,t_notice,tong_zhi where citycode=(select citycode from t_city where cityname='"+cn+"') and productcode=(select productcode from t_product where productname ='"+pn+"')and noticecode=(select noticecode from t_notice where noticename='"+nn+"')and tong_zhi.statecode1 = t_state.statecode and tong_zhi.citycode1 = t_city.citycode and tong_zhi.productcode1=t_product.productcode and tong_zhi.noticecode1 = t_notice.noticecode order by id "
这串赋于变量,设断点调试看这串实际输出是什么, --------------------编程问答-------------------- sql=" ";
OleDbCommand it = new OleDbCommand(sql, conn);
补充:.NET技术 , C#