我在表單應用程序中有兩個ListBoxes
和一個ComboBox
。我想將當前選定的項目從其中3個(兩個ListBoxes
和一個ComboBox
)添加到新的TextBox
。然而,我發現了列名:爲什麼顯示「SYSTEM.DATA.DATAROWVIEW」而不是列名?
SYSTEM.DATA.DATAROWVIEW
下面是我使用的代碼:
private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
{
string cmdstr = @"select * from information_schema.columns where table_name = '" + comboBox1.SelectedItem + "'";
string conStr = @"Data Source=INPDDBA027\NGEP;Initial Catalog=Dev_Server;Integrated Security=True";
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter(cmdstr, conStr);
sda.Fill(dt);
//listBox2.DataSource = dt;
//listBox2.DisplayMember = "Column_Name";
textBox2.CharacterCasing = CharacterCasing.Upper;
textBox2.Text = (listBox1.SelectedItem.ToString() + " " + listBox2.SelectedItem.ToString() + " FROM " + comboBox1.SelectedItem.ToString());
}
請幫助。
看看這個問題:http://stackoverflow.com/questions/34588605/copy-items-from-listbox-to-checkedlistbox –
或者這個:http://stackoverflow.com/questions/34422684/how -can-i-get-the-string-value-of-a-checked-item-from-a-checkedlistbox/ –