August 4, 2008 at 1:24 am
Hi i have two tables from where i have to show data in the datagrid the tables are 1.Contractor and 2.ContractorWorkExp .For that i used two dataset and marge them.After that the dataes are displayed but not in same raw like this
Name workname Amount Date Scheme
mack
constraction 12000 12.2.08 new
Why its coming like this .what i have to do to saw data in the same raw
the codes are.
databind()
{
DataSet ds1 = new DataSet();
DataSet ds2 = new DataSet();
con=new SqlConnection("Server=localhost; Database=cemd; User ID=sa; Password=******;");
da = new SqlDataAdapter("select fname, mname, lname from Contractor where contractorid='" + contractorid + "'", con);
da.Fill(ds1, "Record");
da=new SqlDataAdapter("select * from ContractorWorkExp where contractorid='"+contractorid+"'",con);
da.Fill(ds2, "Record");
ds1.Merge(ds2);
MyDataGrid.DataSource = ds1;
MyDataGrid.DataBind();
}
August 4, 2008 at 6:00 am
Hello,
Instead of having two separate Tables in your DataSet, use just one which joins the two Database Tables together e.g. Select * From Contractor C Left Join ContactorWorkExp CWE On C.ContractorId = CWE.ContractorId
Regards,
John Marsh
www.sql.lu
SQL Server Luxembourg User Group
August 5, 2008 at 12:10 am
but what about the condition contractorid='"+ contractorid+"'
here contractorid=ddlcontractor.selectitem.value
August 5, 2008 at 2:06 am
Hello,
No problem to add a Where clause to the SQL statement. It would then be along the lines of: "Select * From Contractor C Left Join ContactorWorkExp CWE On C.ContractorId = CWE.ContractorId Where C. ContractorId =' "+ contractorid+"'
Regards,
John Marsh
www.sql.lu
SQL Server Luxembourg User Group
August 5, 2008 at 3:41 am
thanks its working
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply