我的表单上有 2 个组合框(在表单加载事件中)。表单加载后,第一个组合框从 select 语句中获取一个值。我想在我的第二个组合框中使用该值。这是我的代码:
第一个组合框 = cbDelivery
OracleConnection conn = new OracleConnection();
conn.ConnectionString = "User Id=christob;Password=CHRISTOB;Host=poseidon;Pooling=true;Min Pool Size=0;Max Pool Size=100;Connection Lifetime=0;Port=1522;Sid=GLODCD";
conn.Open();
string query;
query = "select distinct dd.delivery_bay_code from dc_delivery dd, dc_grv dg where delivery_complete_datetime is null and dd.dc_delivery_id_no = dg.dc_delivery_id_no and dd.delivery_announce_datetime is null";
OracleCommand cmd = new OracleCommand(query, conn);
OracleDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
cbDelivery.Items.Add(dr["delivery_bay_code"]);
}
dr.Close();
conn.Close();
2de 组合框 = cbOrderNo
此组合框位于:
私人无效 cbDelivery_SelectedIndexChanged(对象发送者,EventArgs e)
因此,一旦我从第一个组合框中选择一个值,我的第二个组合框查询就必须填充第二个组合框。见代码:
OracleConnection conn = new OracleConnection();
conn.ConnectionString = "User Id=christob;Password=CHRISTOB;Host=poseidon;Pooling=true;Min Pool Size=0;Max Pool Size=100;Connection Lifetime=0;Port=1522;Sid=GLODCD";
conn.Open();
string query1;
query1 = "select distinct dg.order_no from dc_delivery dd, dc_grv dg where delivery_complete_datetime is null and dd.dc_delivery_id_no = dg.dc_delivery_id_no and dd.delivery_announce_datetime is null and dd.delivery_bay_code = " + cbDelivery.Text;
OracleCommand cmd1 = new OracleCommand(query1, conn);
OracleDataReader dr1 = cmd1.ExecuteReader();
while (dr1.Read())
{
cbOderNo.Items.Add(dr1["order_no"]);
}
dr1.Close();
conn.Close();
注意我在第二个 Select 查询中使用了 cbDelivery 组合框。
问题是:一旦我从第一个组合框中选择一个值,第二个组合框就会给出异常“”ORA-00904:“BAY1”:标识符无效。
请帮我解决这个问题或提出不同的方法。
提前致谢。