关于C#连接ORACLE问题,请教各位老大
我想读取A、B这两表的数据,然后在程序中进行比较,把结果输出到TEXT
private void toolStripLabel1_Click(object sender, EventArgs e)
{
OracleConnection conn = new OracleConnection(System.Configuration.ConfigurationManager.AppSettings.Get( "sjk "));
OracleCommand cmd= new OracleCommand();
conn.Open();
OracleDataAdapter da = new OracleDataAdapter( "select * from a,b ", conn);
DataTable dt = new DataTable();
da.Fill(dt);
conn.Close();
foreach (DataRow myRow in dt.Rows)
{
DepartmetNode node = new DepartmetNode();
node.DeptCode= myRow[ "did "].ToString();
node.DeptName = myRow[ "dname "].ToString();
node.DeptParent = myRow[ "parentid "].ToString();
string str = "select ldap_id from a where a.d_dptname= ' " + node.DeptName + " ' ";
cmd.CommandText = str;
//cmd.ExecuteNonQuery();
textBox1.Text = str + ", ";
}
return;
}
执行程序后,textbox1.text= "select ldap_id from hr_dptdata a where a.d_dptname= '部门1 '
小弟是菜鸟,求教为何如此
------解决方案--------------------没有获得查询结果
SqlDataReader dr =cmd.ExecuteReader();
while(dr.Read)
{
string temp= " ";
textBox1.Text =dr.GetString(0);
}