Click here to Skip to main content
15,901,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone,I have a datatable that is filled up with data from sql server, so can I store all the data rows to the specific string values ex. the datatable has 24 rows, and I want to store all rows on a string values like : string value1 = row1, value2=row2, value3=row3 ... value24=row24, I need an idea please if anyone know how to do it tell me, thanks :)
Posted

DataTable dt=new DataTable();

dt=GetDataTableFromSQL();

string str1=string.empty;
list<string> strLst=new List<string>();
foreach(DataRow dr in dt.Rows)
{
str1+=convert.tostring(dr["ColumnName1"])+convert.tostring(dr["ColumnName2"])+..so on

strLst.add(str1);
}

Now you need to move loop on string list and check rows in string one by one.

foreach(string item in strlst)
{
//item -----
}


Thanks
Prince Sharma
 
Share this answer
 
Comments
Taulant Loshi 24-Jun-13 4:31am    
thanks for your answer I appreciate it but I'm really on trouble, I can't get the solution or maybe I'm not explaining that as It should be :(
You can do something like this.

//foreach row in databasetable
{
//foreach column in databasetable
{
//Concat and build a string.Use StringBuilder
}
//Add the string to your datatable.
}
 
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