Bineesh  Viswanath

Bineesh Viswanath

  • NA
  • 1k
  • 776.3k

How to store multiple value in string[] in C# ADO.NET

Jun 24 2017 3:21 AM
Hi ,
 
I presently in a ADO.NET project which having a issue with retrieving data from db.
 
I am trying to retrieve  and store 4 rows from db  in a string[].
 
 Here my code:-

pasting

string[] strImageLocation = new string[i+1];//Array declaration where i want to store values

strImageLocation[i] = dtblPsprt.Rows[i]["filePath"].ToString();//assinged value from db into array

 Here is the array looks like after loop end.
 
 
My intent is to load different path into array index. But 
 
complete loop c# loop code:-
 

for (int i = 0; i < dtblPsprt.Rows.Count; i++)

{

string[] strImageLocation = new string[i+1];

pbox[i] = new PictureBox();

tbPsprtPBoxPassport.Controls.Add(pbox[i]);

psprtImage = new Byte[i];

psprtImage = (Byte[])(dtblPsprt.Rows[i]["psprtImage"]);

Psprtmem = new MemoryStream(psprtImage);

pbox[i].Image = Image.FromStream(Psprtmem);

tbPsprtPBoxPassport.Image = pbox[i].Image;

strImageLocation[i] = dtblPsprt.Rows[i]["filePath"].ToString();

}

 Please reply with a solution:-
 

Answers (2)