Click here to Skip to main content
15,886,422 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi here i am getting 10 records from database and i used sqldatareader to read those 10 records as follows

sqlDataReader reader = cmd.ExecuteReader();

// in reader, i have records which comes from database.

while(reader.Read())

{

string [] arpp_pro= new string[] {reader["records"].ToString()};

}

everything works fine.. it is not assinging in array position.

while looping at fist time, [0] is having first record

while loopting at second time, [1] is having second record. but here [0] record is not there.

i need.

[0] = firstrecord.

[1] = second record.

[3] = third record.

it assingn correctyl. but i can see one record only.

how to solve this problem. how can i get 10 records.
Posted

1 solution

hope it will helps
use Generic namespace

using System.Collections.Generic;

List <string> arpp_pro = new List<string>();


C#
while(reader.Read())

{
arpp_pro.Add(dr[0].Tostring());
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900