Click here to Skip to main content
14,882,280 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
i want When i take a select from database,data indicate in a column
SQL
ALTER PROCEDURE dbo.StoredProcedure2

AS
    select   Table1.id+Table1.name 
    from Table1

    RETURN


i used stored procedure
Posted
Comments
Mehul M Thakkar 25-Apr-12 3:31am
   
So what is the actual problem?

If a LINQ query is required to merge the DataColumns "Id" and "Name" of a DataTable to get another DataTable with single DataColumn, then the following code can be used.
C#
void Main()
{
    DataTable table1 = new DataTable();
    table1.Columns.Add("Id",typeof(string),null);
    table1.Columns.Add("Name",typeof(string),null);
    table1.Rows.Add("1","Name one");
    table1.Rows.Add("2","Name two");
    table1.Rows.Add("3","Name three");
    
    DataTable table2 = new DataTable();
    table2.Columns.Add("IdName",typeof(string),null);
    
    table1.AsEnumerable().Select (
	row => {DataRow mRow = table2.NewRow();
	mRow["IdName"]= string.Format("{0}: {1}",
		row.Field<string>("Id"),
		row.Field<string>("Name"));
	return mRow;}).CopyToDataTable(table2,
		LoadOption.OverwriteChanges);
}

//table1
//Id Name 
//1 Name one 
//2 Name two 
//3 Name three 
//
//table2
//IdName 
//1: Name one 
//2: Name two 
//3: Name three 
//</string></string>
   
v2
what's the problem you encountered?
   

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