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