Problem of two tables while filling DataSet

  • Thread starter Thread starter savvy
  • Start date Start date
S

savvy

I'm trying to page a datagrid but the when i'm tying to fill the
DataSet with a table, I know that using DataAdapter.Fill you can
specify a single datatable to populate when the sp returns one table.
How do I fill my dataset when the sp is a combination of two tables.
i'm not able to understand how to fill it when i'm using a sql server
stored procedure as given below
any suggestions will be greatly appreciated.
Thanks for your help and time in Advance

-----------------------------------------------------
SELECT AJ.*, CD.* FROM AppliedJobs AS AJ, CVDetails AS CD WHERE
AJ.JS_ID = CD.JS_ID AND AJ.CV_ID= CD.CV_ID AND AJ.JobID=@job_id

-----------------------------------------------------
// and my DataSet in the ASP.NET appplication is which is not working
out ....
objDS = new DataSet();
objcmd = new SqlCommand("SelectJobAppliedCVDetails", objConn);
objcmd.CommandType = CommandType.StoredProcedure;
objcmd.Parameters.Add(new SqlParameter("@job_id",
Request.QueryString["id"]));
objDA = new SqlDataAdapter(objcmd);
objDA.TableMappings.Add("CVDetails1","AppliedJobs");
objDA.Fill(objDS, "CVDetails");
dgresponsedetails.DataSource = objDS.Tables[0].DefaultView;
dgresponsedetails.DataBind();
objConn.Close();
----------------------------------------------------------
 
Your SP Is doing a simple join on 2 tables. It is going to return one table
only.

What do you mean "not working"? What is happening and what are you
expecting?
 
objDA.TableMappings.Add("CVDetails1","AppliedJobs");
objDA.Fill(objDS, "CVDetails");

Though i've coded as shown above, i'm able to only see either
AppliedJobs details or CVDetails details but not both.
When its returning only one table then what table name should i use to
fill the DataSet . Are the above two lines in the
correct format?
Thanks in Advance
 
Back
Top