Click here to Skip to main content
15,886,422 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to get data from databse. Ex: Id,Name
i want to view this data in a string, it shown like 1,Rakesh
2,Raju etc.

One function is there, this function get data from database and view like this:

string str=getStudent();

How can i do this
Posted
Comments
senguptaamlan 18-May-11 8:35am    
what you have done??? please post the same....(any code)...or if you want to do from scratch please do a google search....basic knowledge of ADO.NET can solve this...so try a bit more...

You could do this is a number of ways.
One way would be to do this via a query.
select Id + ',' + firstname from myTable

The second way would be to get all the values into a data reader, loop through the reader and concatenate all the selected parameters. This would be done in the client side code.
 
Share this answer
 
Select ID, Name From TABLENAME
 
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