I want to store each Datatable Column in a string variable so that i can pass all these parameters to my stored procedure.
This will go on for each row in DataTable
DataTable dtOutput;
dtOutput= Generix.getFeedData(1,ref Connection);
foreach (DataRow drOutput in dtOutput.Rows)
{
Console.Write("IST: ");
foreach (DataColumn dcOutput in dtOutput.Columns)
{
Console.Write(Convert.ToString(drOutput[dcOutput]) + "\t");
}
Console.WriteLine();
}
Above Code should Print Each Column and a "\t" as separator and new row on new line.My DataTable Contains 4 Columns
My DataTable Prints in Following Way:
ATM Message
ABC001 Hello
ABC002 SAGAR
Now i want in following way:
string sAtm;// Should Print ABC001
string sMsg;//Should Print Hello
For Next Row Value in sAtm will be ABC002
For what it’s worth, you could use Linq to get all params as string.
Pick out what you need:
So if you for example want to iterate all rows and get specific fields:
Remember to add
using system.Linq;.Edit: If you instead want to save the whole DataTable in one string: