Click here to Skip to main content
15,888,072 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
My Current Dataset in Table[0]

Id  |   Name    |  City
1   |  Akshada  |  Baroda
2   |  Rutu     |  Pune


Second Dataset Table [1]
Cast
Bramhin 
Rajput 
Muslim



I Want Below Answer 

Id  |   Name    |  City    | Cast
1   |  Akshada  |  Baroda  | Bramhin
2   |  Rutu     |  Pune    | Rajput
3   |  Priya    |  Jaipur  | Muslim


What I have tried:

pSqlParameter = new SqlParameter[1];

                pSqlParameter[0] = new SqlParameter("@BatchId", SqlDbType.Int);
                pSqlParameter[0].Direction = ParameterDirection.Input;
                pSqlParameter[0].Value = intBatchId;

                strStoredProcName = "usp_tbl_TestSampleResult_SelectALL_ForDisplay";                

                DataSet dsResult = new DataSet();
                dsResult = Database.ExecuteDataSet(CommandType.StoredProcedure, strStoredProcName, pSqlParameter);

                //ApplicationResult objResults = new ApplicationResult(dsResult);
                //objResults.Status = ApplicationResult.CommonStatusType.Success;
                //return objResults;


                strStoredProcNameTwo = "usp_tbl_TestSampleResult_SelectALL_ForDisplay_ParameterResult";
                DataSet dsResult1 = new DataSet();

                dsResult1 = Database.ExecuteDataSet(CommandType.StoredProcedure, strStoredProcNameTwo, pSqlParameter);
                dsResult.Merge(dsResult1);

                ApplicationResult objResults = new ApplicationResult(dsResult);
                objResults.Status = ApplicationResult.CommonStatusType.Success;
                return objResults;
Posted
Updated 5-Aug-18 18:16pm

Thank you all for helping me i got solution using below code



objResult.ResutlDs.Tables[0].Columns.Add("Cast", typeof(string));
for (int i = 0; i < objResult.ResutlDs.Tables[0].Rows.Count; i++)
{
     objResult.ResutlDs.Tables[0].Rows[i]["Cast"] = objResult.ResutlDs.Tables[2].Rows[i]["Cast"];
}
 
Share this answer
 
I guess you have to learn innerjoin,leftjoin that will help you join table and get colume from 2 table with first and display together
This is an example try this

SELECT Orders.OrderID, Customers.CustomerName
FROM Orders
INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID;
 
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