Dear there,
Actually I would like to populate or fill my checkbox from data from database. How can I do it? The data in DB table attribute is "Status" so either 1 or 0 if it's 1 Select the checkbox. I have Window Form.
Here is my code:
Thank in advance.
Actually I would like to populate or fill my checkbox from data from database. How can I do it? The data in DB table attribute is "Status" so either 1 or 0 if it's 1 Select the checkbox. I have Window Form.
Here is my code:
Code:
private void bringdata() { // select a data SQL = "SELECT * FROM trafic"; // command phrase cmd = new OracleCommand(SQL, conn); cmd.CommandType = CommandType.Text; xx = cmd.ExecuteReader(); if (xx.Read()) { readdata(); } } private void readdata() { this.textBox3.Text = Convert.ToString(xx["id"]); this.textBox1.Text = Convert.ToString(xx["comp_name"]); this.textBox2.Text = Convert.ToString(xx["comp_type"]); this.richTextBox1.Text = Convert.ToString(xx["describe"]); this.checkBox1.Text = Convert.ToString(xx["status"]); } private void Create_user_Load(object sender, EventArgs e) { string oradb = "Data Source=XE;User Id=hr;Password=hr;"; conn = new OracleConnection(oradb); if (conn.State == ConnectionState.Closed) { conn.Open(); } bringdata(); this.Refresh(); }
Thank in advance.
Comment