Privesh
Privesh

Reputation: 657

dynamic checkboxes

I am new to C#.

I have about 55 checkboxes on a form to choose vaious different options, the labels and labels are dependant on 'frmSchemas.schema' from a previous form.

Is there any way I can get the values from the database to populate on the comboxes dynamically so I dont have to code to read 189 times?

I am sorry if I didnt ask the correct question. I am using the code below but stuck after the dr.Read(); Can anyone help me...

string oradb = "Data Source=";
oradb = oradb + Login.db + ";";
oradb = oradb + "User Id=" + Login.user;
oradb = oradb + ";Password=" + Login.pass + ";";
OracleConnection conn = new OracleConnection(oradb);
conn.Open();
sql = "SELECT GCOS_SCHEMA, PROGRAM_FIELD, DBFIELD,PROGRAM_LABEL FROM GENDBA.SUPTALLYACTIVITIESCONFIG where active ='Y' and GCOS_SCHEMA ='" + frmSchemas.schema + "'";
OracleCommand cmd = new OracleCommand(sql, conn);
cmd.CommandType = CommandType.Text;
OracleDataReader dr = cmd.ExecuteReader();
dr.Read();

Upvotes: 0

Views: 230

Answers (2)

Nika G.
Nika G.

Reputation: 2384

if your problem is 55 checkboxes, thus 55 diff names to work/code with, switch to CheckBoxList for asp.net or CheckedListBox for winforms.

Upvotes: 0

DeveloperX
DeveloperX

Reputation: 4683

change dr.Read(); to

while(dr.Read())
{
 // loop through the table 

}

Upvotes: 2

Related Questions