0
我有一個組框包含單選按鈕,例如。如何從數據庫檢索單選按鈕值使用C#
O級1
O級2
如何我可以加載數據庫的價值和對我的GUI檢查無線電鈕?
private void button_clone_Click(object sender, EventArgs e)
{
try
{
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
command.CommandText = "SELECT * from PPAPdatabase where [PSW ID]=" + txt_c_PSW_ID.Text + "";
OleDbDataReader dr = null;
dr = command.ExecuteReader();
while (dr.Read())
{
comboBox_PPAP.Text = (dr["Reason"].ToString());
checkedListBox_prodline.Text = (dr["Production Line"].ToString());
checkedListBox_owner.Text = (dr["Owner"].ToString());
txt_comment.Text = (dr["Comment"].ToString());
}
}
catch (Exception ex)
{
MessageBox.Show("An error has occurred: " + ex.Message,
"Important Note",
MessageBoxButtons.OK,
MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1);
}
finally
{
connection.Close();
}
在此先感謝!
UI什麼樣的,Windows窗體,asp.net? –
你試圖綁定單選按鈕的是什麼樣的數據?它有點,字符串,整數列? –
@BrianMains從應用程序的窗口 – NOGRP90