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. C#

C#

Scheduled Pinned Locked Moved C#
databasecsharp
4 Posts 4 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.
  • J Offline
    J Offline
    Jaleel Ahmed
    wrote on last edited by
    #1

    Hi, I had a database in access I want to connect through connection string where shall I write the connection string so that it is written once & can be use at different places through out the project. Second I want to get data in a combobox using that same connection & using a select query at the time of form load in C# Please suggest . THanks

    P A K 3 Replies Last reply
    0
    • J Jaleel Ahmed

      Hi, I had a database in access I want to connect through connection string where shall I write the connection string so that it is written once & can be use at different places through out the project. Second I want to get data in a combobox using that same connection & using a select query at the time of form load in C# Please suggest . THanks

      P Offline
      P Offline
      Paul Conrad
      wrote on last edited by
      #2

      Jaleel Ahmed wrote:

      where shall I write the connection string so that it is written once & can be use at different places through out the project

      Generally it should be in your app.config file.

      "Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus

      1 Reply Last reply
      0
      • J Jaleel Ahmed

        Hi, I had a database in access I want to connect through connection string where shall I write the connection string so that it is written once & can be use at different places through out the project. Second I want to get data in a combobox using that same connection & using a select query at the time of form load in C# Please suggest . THanks

        A Offline
        A Offline
        Abhinav S
        wrote on last edited by
        #3

        Jaleel Ahmed wrote:

        Second I want to get data in a combobox using that same connection & using a select query at the time of form load in C#

        Fire the query in the Form_Load event.

        WP7.5 Apps - XKCD | Calvin | SMBC | Sound Meter | Speed Dial

        1 Reply Last reply
        0
        • J Jaleel Ahmed

          Hi, I had a database in access I want to connect through connection string where shall I write the connection string so that it is written once & can be use at different places through out the project. Second I want to get data in a combobox using that same connection & using a select query at the time of form load in C# Please suggest . THanks

          K Offline
          K Offline
          KiranKumar Roy
          wrote on last edited by
          #4

          Hello, You can use below code to fill Combobox on your form load even.

          private void Form1_Load(object sender, EventArgs e)
          {
          DataTable dt = new DataTable();
          dt = FillDT();
          this.cmbTempControl.DataSource = dt;
          this.cmbTempControl.ValueMember = "ID";
          this.cmbTempControl.DisplayMember = "Name";
          }

              protected DataTable FillDataTable()
              {
                  DataTable dtTemp = new DataTable();
                  /\*Write here code to Fill your Datatable form Database \*/
                  return dtTemp;
              }
          

          Thanks

          KiranKumar Roy

          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