2016-06-20 3 views
0

그룹 상자에 라디오 버튼이 있습니다.C#을 사용하여 데이터베이스에서 라디오 버튼 값을 가져 오는 방법

O 레벨 1

O 레벨 2

어떻게 데이터베이스에서 값을로드하고 내 GUI에 라디오 botton을 확인할 수 있습니다?

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(); 
    } 

미리 감사드립니다.

+0

UI 어떤 종류의, 창 형태, asp.net을? –

+0

라디오 버튼을 바인딩하려는 데이터의 종류는 무엇입니까? 비트, 문자열, 정수 열입니까? –

+0

@BrianMains applications from application – NOGRP90

답변

1

가정 라디오 버튼을 radioButton1이라고하고 어느 1 또는 0으로 저장 값을 참조하는 열은 당신이 할 것 :

radioButton1.Checked = row["PPAP"].ToString() == "1"; 
+0

감사합니다. 그것은 작동합니다! – NOGRP90

관련 문제