关于c#combobox绑定数据库,从后台获取text值出现System.Data.DataView

 


OleDbConnection conn = new OleDbConnection("Provider=OraOLEDB.Oracle;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost) (PORT=1521)))(CONNECT_DATA=(SERVICE_NAME= XXXXX)));User Id=XXXXX;Password=XXXX;");

            conn.Open();

            DataSet myds2 = new DataSet();

            string Pid = comboBox1.SelectedValue.ToString();

            string mysql2 = "SELECT * FROM CITY  WHERE PROVINCEID =" + Pid;

            Console.WriteLine(mysql2);

            OleDbDataAdapter myda2 = new OleDbDataAdapter(mysql2, conn);

            myda2.Fill(myds2, "CITY");

            Console.Write(myds2.Tables["CITY"]);

            comboBox2.DisplayMember = "NAME";

            comboBox2.ValueMember = "CODE";

            comboBox2.DataSource = myds2.Tables["CITY"];

            conn.Close();

            DataRowView drv1 = (DataRowView)comboBox1.SelectedItem;

            textBox1.Text = drv1.Row[2].ToString();

红色部分是解决方法


你可能感兴趣的:(关于c#combobox绑定数据库,从后台获取text值出现System.Data.DataView)