Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB.NET
public DataSet GetAllcarDetails()
       {

// Code here

C#
DataSet ds = new DataSet();
           ds = sqlClientConn.ltDataSet(ltSqlParams);
           return ds;

}

i want to return List instead of dataset.

i tried this

C#
//for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
           //{
           //    list = ds.Tables[0].AsEnumerable().Select(r => r.Field<string>("Voucher_No")).ToList();
           //   
           //}

The ds contains 5 columns, above code does only return one column i.e("Voucher_No").How to get multiple columns?
Posted
Updated 20-Nov-15 2:40am
v2
Comments
Tomas Takac 20-Nov-15 8:26am    
Not clear. What list? Where do you convert the dataset to a list? What do you want to do with that list? Please provide more details.
Sathish km 20-Nov-15 8:41am    
That one i'm asking. I have updated my question see that.

1 solution

Try using loop-
C#
List<string> voucherList = new List<string>();
foreach(DataRow dr in ds.Tables[0].Rows)
{
    voucherList.Add(dr["Voucher_No"].Tostring());
}
// do something with the voucherList</string></string>


-KR
 
Share this answer
 
Comments
Sathish km 20-Nov-15 8:56am    
Thanks a lot...
Krunal Rohit 20-Nov-15 10:48am    
Glad I could help.
Cheers. :)

-KR

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