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. General Programming
  3. C#
  4. Return Dataset to Business Layer & SHOW in datagrid in Presentation Layer

Return Dataset to Business Layer & SHOW in datagrid in Presentation Layer

Scheduled Pinned Locked Moved C#
businessquestion
11 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.
  • S Offline
    S Offline
    shahramkeyboard
    wrote on last edited by
    #1

    hi how i can return dataset to datagriedview My business layer is memberBL Class My Data Access Layer Is memberDA Class My view Dataset Code in memberDL Class is:

    public DataSet View(memberBL member)
    {
    DataSet ds = null;

            try
            {
                OpenCnn();
                
                String selectStr = "select \* from " + thisTable + "'";
                
                OleDbDataAdapter da =new OleDbDataAdapter(selectStr, cnn);
                
                ds = new DataSet();
                
                da.Fill(ds, thisTable);
                
                CloseCnn();
            }
            catch (Exception e)
            {
                String Str = e.Message;
            }
    
            return ds;
        }
    

    How I Can return Dataset in GriedView in Form? hoW i can use in ds IN windows FORM?

    D S D 3 Replies Last reply
    0
    • S shahramkeyboard

      hi how i can return dataset to datagriedview My business layer is memberBL Class My Data Access Layer Is memberDA Class My view Dataset Code in memberDL Class is:

      public DataSet View(memberBL member)
      {
      DataSet ds = null;

              try
              {
                  OpenCnn();
                  
                  String selectStr = "select \* from " + thisTable + "'";
                  
                  OleDbDataAdapter da =new OleDbDataAdapter(selectStr, cnn);
                  
                  ds = new DataSet();
                  
                  da.Fill(ds, thisTable);
                  
                  CloseCnn();
              }
              catch (Exception e)
              {
                  String Str = e.Message;
              }
      
              return ds;
          }
      

      How I Can return Dataset in GriedView in Form? hoW i can use in ds IN windows FORM?

      D Offline
      D Offline
      Dan Mos
      wrote on last edited by
      #2

      well that's easy. Something like:

      dataGridView1.DataSource = ds.Tables[0];//or ds.Tables["YourTableNameHere"];

      1 Reply Last reply
      0
      • S shahramkeyboard

        hi how i can return dataset to datagriedview My business layer is memberBL Class My Data Access Layer Is memberDA Class My view Dataset Code in memberDL Class is:

        public DataSet View(memberBL member)
        {
        DataSet ds = null;

                try
                {
                    OpenCnn();
                    
                    String selectStr = "select \* from " + thisTable + "'";
                    
                    OleDbDataAdapter da =new OleDbDataAdapter(selectStr, cnn);
                    
                    ds = new DataSet();
                    
                    da.Fill(ds, thisTable);
                    
                    CloseCnn();
                }
                catch (Exception e)
                {
                    String Str = e.Message;
                }
        
                return ds;
            }
        

        How I Can return Dataset in GriedView in Form? hoW i can use in ds IN windows FORM?

        S Offline
        S Offline
        shahramkeyboard
        wrote on last edited by
        #3

        program is layering & ds in not known in form first ds come in business layer then view in datagried it is not easy my dear friend:confused:

        D 1 Reply Last reply
        0
        • S shahramkeyboard

          program is layering & ds in not known in form first ds come in business layer then view in datagried it is not easy my dear friend:confused:

          D Offline
          D Offline
          Dan Mos
          wrote on last edited by
          #4

          I'm sorry I don't understand. what do you mean by "ds in not known in form"? An by this "first ds come in business layer then view in datagried"? Do you have problem returnig the dataset from your bussines layer to your UI?

          S 1 Reply Last reply
          0
          • D Dan Mos

            I'm sorry I don't understand. what do you mean by "ds in not known in form"? An by this "first ds come in business layer then view in datagried"? Do you have problem returnig the dataset from your bussines layer to your UI?

            S Offline
            S Offline
            shahramkeyboard
            wrote on last edited by
            #5

            yes first ds to business layer then view in UI layer & form

            D 1 Reply Last reply
            0
            • S shahramkeyboard

              yes first ds to business layer then view in UI layer & form

              D Offline
              D Offline
              Dan Mos
              wrote on last edited by
              #6

              I got that from your anteriour posts. But what is your problem? Passing data from the BLogic to the UI or just the UI part? [EDIT] OK suppose that your UI is in the MyUI namespace. The BussinessLayer is in the MyLogic namespace. in order to populate your UI with data do something like this inside a click event for example:

              private void btn1_Click(object sender, EventArgs null){
              dataGridView1.DataSource = MyLogic.MemberBL.GetDataSet().Tables[0];
              //where the GetDataSet() returns the ds from the BussinessLayer;
              }

              Just like d@nish said if on a different project/dll just add a reference to it.

              S 1 Reply Last reply
              0
              • S shahramkeyboard

                hi how i can return dataset to datagriedview My business layer is memberBL Class My Data Access Layer Is memberDA Class My view Dataset Code in memberDL Class is:

                public DataSet View(memberBL member)
                {
                DataSet ds = null;

                        try
                        {
                            OpenCnn();
                            
                            String selectStr = "select \* from " + thisTable + "'";
                            
                            OleDbDataAdapter da =new OleDbDataAdapter(selectStr, cnn);
                            
                            ds = new DataSet();
                            
                            da.Fill(ds, thisTable);
                            
                            CloseCnn();
                        }
                        catch (Exception e)
                        {
                            String Str = e.Message;
                        }
                
                        return ds;
                    }
                

                How I Can return Dataset in GriedView in Form? hoW i can use in ds IN windows FORM?

                D Offline
                D Offline
                dan sh
                wrote on last edited by
                #7

                If everything is in same project, create an instance of your BL class and then call the method which returns the dataset. If BL is in separate project, add a reference to that project in your UI project and then do the same.

                S 1 Reply Last reply
                0
                • D Dan Mos

                  I got that from your anteriour posts. But what is your problem? Passing data from the BLogic to the UI or just the UI part? [EDIT] OK suppose that your UI is in the MyUI namespace. The BussinessLayer is in the MyLogic namespace. in order to populate your UI with data do something like this inside a click event for example:

                  private void btn1_Click(object sender, EventArgs null){
                  dataGridView1.DataSource = MyLogic.MemberBL.GetDataSet().Tables[0];
                  //where the GetDataSet() returns the ds from the BussinessLayer;
                  }

                  Just like d@nish said if on a different project/dll just add a reference to it.

                  S Offline
                  S Offline
                  shahramkeyboard
                  wrote on last edited by
                  #8

                  my business layer is: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Library_Project { class memberBL { //Book properties private String membercode; private String name; private String family; private String shsh; private String melicode; private String tavalod; private String shoghl; private String tel; private String mobile; private String adr; private String trkhozv; private memberDA memberData; // BUSINESS LOGIC Member public memberBL() { //Data access layer! memberData = new memberDA(); } /// <SUMMARY> /// Property BookCode (String) /// </SUMMARY> public String DatasetData { get { return this.DatasetData; } set { this.DatasetData = value; } } /// <SUMMARY> /// Property BookCode (String) /// </SUMMARY> public String Membercode { get { return this.membercode; } set { this.membercode = value; } } /// <SUMMARY> /// Property BooktName (String) /// </SUMMARY> public String Name { get { return this.name; } set { try { this.name = value; if (this.name == "") { throw new Exception( "لطفا نام عضو را وارد نمایید"); } } catch(Exception e) { throw new Exception(e.Message.ToString()); } } } /// <SUMMARY> /// Property ISBN (String) /// </SUMMARY> public String Familly {

                  D 1 Reply Last reply
                  0
                  • D dan sh

                    If everything is in same project, create an instance of your BL class and then call the method which returns the dataset. If BL is in separate project, add a reference to that project in your UI project and then do the same.

                    S Offline
                    S Offline
                    shahramkeyboard
                    wrote on last edited by
                    #9

                    My Business Lyaer Is:

                    using System;
                    using System.Collections.Generic;
                    using System.Data.OleDb;
                    using System.Text;
                    using System.Data;

                    namespace Library_Project
                    {
                    class memberBL
                    {
                    //Book properties
                    private String membercode;
                    private String name;
                    private String family;
                    private String shsh;
                    private String melicode;
                    private String tavalod;
                    private String shoghl;
                    private String tel;
                    private String mobile;
                    private String adr;
                    private String trkhozv;

                            private memberDA memberData;
                    
                       // BUSINESS LOGIC Member 
                       public memberBL()            
                       {
                         
                           //Data access layer!
                     
                           memberData = new memberDA();
                    
                       }
                       /// <SUMMARY>
                       /// Property BookCode (String)
                       /// </SUMMARY>
                       public String Membercode
                       {
                           get
                           {
                               return this.membercode;
                           }
                           set
                           {
                               this.membercode = value;
                    
                    
                           }
                       }
                    
                            /// <SUMMARY>
                            /// Property BooktName (String)
                            /// </SUMMARY>
                            public String Name 
                            {
                      
                                  get
                                  {
                                      return this.name;
                                  }
                                  set
                                  {
                                        try
                                        {
                                            this.name = value;
                    
                                            if (this.name == "")
                                              {
                                                    throw new Exception(
                                                      "لطفا نام عضو را وارد نمایید");
                                              }
                                        }
                                        catch(Exception e)
                                        {
                                              throw new Exception(e.Message.ToString());
                                        }
                                  }
                            }
                    
                            /// <SUMMARY>
                            /// Property ISBN (String)
                            /// </SUMMARY>
                            public String Familly
                            {
                                  get
                                  {
                                        return this.family;
                                  }
                                  set
                                  {
                                        //could be more checkings here eg revmove ' chars
                                        //change to proper case
                                        /
                    
                    S 1 Reply Last reply
                    0
                    • S shahramkeyboard

                      My Business Lyaer Is:

                      using System;
                      using System.Collections.Generic;
                      using System.Data.OleDb;
                      using System.Text;
                      using System.Data;

                      namespace Library_Project
                      {
                      class memberBL
                      {
                      //Book properties
                      private String membercode;
                      private String name;
                      private String family;
                      private String shsh;
                      private String melicode;
                      private String tavalod;
                      private String shoghl;
                      private String tel;
                      private String mobile;
                      private String adr;
                      private String trkhozv;

                              private memberDA memberData;
                      
                         // BUSINESS LOGIC Member 
                         public memberBL()            
                         {
                           
                             //Data access layer!
                       
                             memberData = new memberDA();
                      
                         }
                         /// <SUMMARY>
                         /// Property BookCode (String)
                         /// </SUMMARY>
                         public String Membercode
                         {
                             get
                             {
                                 return this.membercode;
                             }
                             set
                             {
                                 this.membercode = value;
                      
                      
                             }
                         }
                      
                              /// <SUMMARY>
                              /// Property BooktName (String)
                              /// </SUMMARY>
                              public String Name 
                              {
                        
                                    get
                                    {
                                        return this.name;
                                    }
                                    set
                                    {
                                          try
                                          {
                                              this.name = value;
                      
                                              if (this.name == "")
                                                {
                                                      throw new Exception(
                                                        "لطفا نام عضو را وارد نمایید");
                                                }
                                          }
                                          catch(Exception e)
                                          {
                                                throw new Exception(e.Message.ToString());
                                          }
                                    }
                              }
                      
                              /// <SUMMARY>
                              /// Property ISBN (String)
                              /// </SUMMARY>
                              public String Familly
                              {
                                    get
                                    {
                                          return this.family;
                                    }
                                    set
                                    {
                                          //could be more checkings here eg revmove ' chars
                                          //change to proper case
                                          /
                      
                      S Offline
                      S Offline
                      shahramkeyboard
                      wrote on last edited by
                      #10

                      How ds trasnsfer to Business Layer & Then View in form? BUSINESS LAYER & DATA LAYER CODE IS above

                      1 Reply Last reply
                      0
                      • S shahramkeyboard

                        my business layer is: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Library_Project { class memberBL { //Book properties private String membercode; private String name; private String family; private String shsh; private String melicode; private String tavalod; private String shoghl; private String tel; private String mobile; private String adr; private String trkhozv; private memberDA memberData; // BUSINESS LOGIC Member public memberBL() { //Data access layer! memberData = new memberDA(); } /// <SUMMARY> /// Property BookCode (String) /// </SUMMARY> public String DatasetData { get { return this.DatasetData; } set { this.DatasetData = value; } } /// <SUMMARY> /// Property BookCode (String) /// </SUMMARY> public String Membercode { get { return this.membercode; } set { this.membercode = value; } } /// <SUMMARY> /// Property BooktName (String) /// </SUMMARY> public String Name { get { return this.name; } set { try { this.name = value; if (this.name == "") { throw new Exception( "لطفا نام عضو را وارد نمایید"); } } catch(Exception e) { throw new Exception(e.Message.ToString()); } } } /// <SUMMARY> /// Property ISBN (String) /// </SUMMARY> public String Familly {

                        D Offline
                        D Offline
                        Dan Mos
                        wrote on last edited by
                        #11

                        Somthing like this:

                        //in the business layer create a method or property that gets the
                        //data from the DataLayer. Something like this:
                        public DataSet GetDatas(){
                        return memberData.View();
                        }

                        //Now in the UI do something like this
                        LibraryProject.MemberBL bl = new LibraryProject.MemberBL();

                        dataGridView1.DataSource = bl.GetDatas().Tables[0];

                        [Edit]Fixed pre tags[/EDIT]

                        modified on Sunday, February 21, 2010 10:58 PM

                        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