how to set many datasets to a single datable using data adapter in asp.net 1.1 version
-
Only a dataset can have many tables. For filling a dataset,
adapterObj.Fill(dataset1,"Tblname1"); adapterObj.Fill(dataset2,"Tblname2");
to access a table,Datatable dt1 = dataset1.Tables["Tblname1"]; string str = dt1.Rows[0]["Column1"].ToString().Trim();
Can u please tell your exact requirement? -
A datatable will have only one table but a dataset can have multiple tables. If you have data required from two tables then join those multiple tables and assign to a dataset then further to a datatable. I guess....
Gautham
-
Only a dataset can have many tables. For filling a dataset,
adapterObj.Fill(dataset1,"Tblname1"); adapterObj.Fill(dataset2,"Tblname2");
to access a table,Datatable dt1 = dataset1.Tables["Tblname1"]; string str = dt1.Rows[0]["Column1"].ToString().Trim();
Can u please tell your exact requirement?SqlCommand cmdDesign = new SqlCommand(); cmdDesign.Connection = Cn; cmdDesign.CommandType = CommandType.StoredProcedure; cmdDesign.CommandText = "EIS_spGetEmployeeCategory"; cmdDesign.Parameters.Add("@User_Id", SqlDbType.Int).Value = intUserId; SqlDataAdapter daDesign = new SqlDataAdapter(); daDesign.SelectCommand = cmdDesign; daDesign.Fill(ds, "EmpCat"); SqlCommand cmdEdu = new SqlCommand(); cmdEdu.Connection = Cn; cmdEdu.CommandType = CommandType.StoredProcedure; cmdEdu.CommandText = "EIS_spGetEmployeeBasicQualificationList"; cmdEdu.Parameters.Add("@Id", SqlDbType.Int).Value = intUserId; SqlDataAdapter daEdu = new SqlDataAdapter(); daEdu.SelectCommand = cmdEdu; daEdu.Fill(ds, "EmpEdu"); string fileName = Server.MapPath("."); fileName = fileName + "\\Templates\\Resume_Template2.xml"; XmlDocument xmlTemplateDoc = new XmlDocument(); xmlTemplateDoc.Load(fileName); CExWordMLFiller wfiller = new CExWordMLFiller(ds, xmlTemplateDoc.OuterXml); wfiller.Transform(); string copyFileName = Path.GetTempFileName() + ".xml"; wfiller.WordMLDocument.Save(copyFileName); Response.Clear(); Response.ContentType = "application/msword"; Response.Charset = ""; Response.AddHeader("Content-disposition", "inline: filename=" + copyFileName + ""); Response.WriteFile(copyFileName); Response.Flush(); Response.Close();
This was the code i used earlier.But i want to split this code so that each dataset in separate functions in class.There comes the trouble. CExWordMLFiller wfiller = new CExWordMLFiller(ds, xmlTemplateDoc.OuterXml); This 'ds' comprises all datasets.. This is the new code..:public DataSet GetEmployeeCategory (int userId) { DataView dvTemplate = null; int templateId=0; string SP = DBObjectName.spGetEmployeeCategory; Hashtable htParameters = new Hashtable(); htParameters.Add("@User_Id",MISUtility.CheckNull(templateId)); DataSet EmpCat = new DataSet(); try { OpenConnection(); dvTemplate = Connection.ExecuteProcedure(SP,htParameters); DataTable dtTmp = dvTemplate.Table; EmpCat.Tables.Add(dtTmp); } catch(Exception e) { throw new MISException("AdvancedReport.GetEmployeeCategory() failed",e); } finally {