0

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

2 Answers 2

2

change dr.Read(); to

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

}
Sign up to request clarification or add additional context in comments.

3 Comments

i thought of that but what puzzles me is how to assign them to the checkboxes?
use dr[ fieldname] to read the reader value ,and assign it to checkbox,if it isnt, explain more
which would mean that i have to do this for all checkboxes, right?
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.