Populate an Array with DB records

  • Thread starter Thread starter Guilherme Grillo
  • Start date Start date
G

Guilherme Grillo

Hi Friends,

How can I populate an Array with the information of an Table in SQL?

Thanks... and sorry my english...

Grillo
 
Thank you Mark Rae....

Solve my problem!

Now I have another problem.


try

{

int[] pointList = new Int32[60];

int[] idList = new Int32[60];

int i;

for (i = 1; i <= 57; i++)

{

// Cria o comando que seleciona os resultados atuais

commSELECT = new SqlCommand("SELECT * FROM contResults WHERE id = " + i +
"", conn);

// Executa o comando e coloca os resultados em uma Matriz

conn.Open();

readerSELECT = commSELECT.ExecuteReader(CommandBehavior.CloseConnection);

readerSELECT.Read();

pointList = readerSELECT["contResults"];

idList = readerSELECT["id"];

readerSELECT.Close();


Error 1 Cannot implicitly convert type 'object' to 'int'. An explicit
conversion exists (are you missing a cast?)

How can I convert this type????

Here I have the same error:

*int[] respostasList = new Int32[20];

respostasList[1] = RadioButtonList1.SelectedItem.Value;


Sorry my english and thanks again.

Grillo
 
Problem Solved!

Thanks everybody....
Grillo

ps: sorry my english..


Guilherme Grillo said:
Thank you Mark Rae....

Solve my problem!

Now I have another problem.


try

{

int[] pointList = new Int32[60];

int[] idList = new Int32[60];

int i;

for (i = 1; i <= 57; i++)

{

// Cria o comando que seleciona os resultados atuais

commSELECT = new SqlCommand("SELECT * FROM contResults WHERE id = " + i +
"", conn);

// Executa o comando e coloca os resultados em uma Matriz

conn.Open();

readerSELECT = commSELECT.ExecuteReader(CommandBehavior.CloseConnection);

readerSELECT.Read();

pointList = readerSELECT["contResults"];

idList = readerSELECT["id"];

readerSELECT.Close();


Error 1 Cannot implicitly convert type 'object' to 'int'. An explicit
conversion exists (are you missing a cast?)

How can I convert this type????

Here I have the same error:

*int[] respostasList = new Int32[20];

respostasList[1] = RadioButtonList1.SelectedItem.Value;


Sorry my english and thanks again.

Grillo
 
Back
Top