Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to set many datasets to a single datable using data adapter in asp.net 1.1 version

how to set many datasets to a single datable using data adapter in asp.net 1.1 version

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nettutorialannouncement
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    puthu
    wrote on last edited by
    #1

    :((

    V G 2 Replies Last reply
    0
    • P puthu

      :((

      V Offline
      V Offline
      Vsree
      wrote on last edited by
      #2

      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?

      P 1 Reply Last reply
      0
      • P puthu

        :((

        G Offline
        G Offline
        gauthee
        wrote on last edited by
        #3

        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

        P 1 Reply Last reply
        0
        • G gauthee

          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

          P Offline
          P Offline
          puthu
          wrote on last edited by
          #4

          Can u please explain how can i write the code for that... Thankin u in anticipation.:-D

          1 Reply Last reply
          0
          • V Vsree

            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?

            P Offline
            P Offline
            puthu
            wrote on last edited by
            #5

            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 {

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups