我在表单应用程序中有两个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/ –