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. Tabels & Comboboxes

Tabels & Comboboxes

Scheduled Pinned Locked Moved C#
databasequestion
5 Posts 2 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.
  • T Offline
    T Offline
    The underdog
    wrote on last edited by
    #1

    Hi I got an access database. is it possible to put the tables of this database in a combobox? If yes then how? the underdog

    U 1 Reply Last reply
    0
    • T The underdog

      Hi I got an access database. is it possible to put the tables of this database in a combobox? If yes then how? the underdog

      U Offline
      U Offline
      Utku KAYA
      wrote on last edited by
      #2

      Hi Use the following snippet for retrieving table names.... OleDbConnection connection = new OleDbConnection(); connection.Open(); object[] restrictions; restrictions = new object[] {null , null , null , "TABLE"}; DataTable table; table = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Columns,restrictions); connection.Close(); then, this.cmbTables.DataSource = table; this.cmbTables.DisplayMember = "TABLE"; I hope it works for you.

      U 1 Reply Last reply
      0
      • U Utku KAYA

        Hi Use the following snippet for retrieving table names.... OleDbConnection connection = new OleDbConnection(); connection.Open(); object[] restrictions; restrictions = new object[] {null , null , null , "TABLE"}; DataTable table; table = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Columns,restrictions); connection.Close(); then, this.cmbTables.DataSource = table; this.cmbTables.DisplayMember = "TABLE"; I hope it works for you.

        U Offline
        U Offline
        Utku KAYA
        wrote on last edited by
        #3

        First of all get rid of the new table names stuff and check if you can read data from the tables by using your OleDb code. Fill some sample data in Access and use .. . . . . string sqlSelectStatement = "SELECT * FROM "; OleDbDataAdapter adapter = new OleDbDataAdapter =(sqlSelectStatement,connection); connection.Open(); DataTable table = new DataTable(); try { adapter.Fill(table); } connection.Close(); Now look in table and tell the result.

        T 1 Reply Last reply
        0
        • U Utku KAYA

          First of all get rid of the new table names stuff and check if you can read data from the tables by using your OleDb code. Fill some sample data in Access and use .. . . . . string sqlSelectStatement = "SELECT * FROM "; OleDbDataAdapter adapter = new OleDbDataAdapter =(sqlSelectStatement,connection); connection.Open(); DataTable table = new DataTable(); try { adapter.Fill(table); } connection.Close(); Now look in table and tell the result.

          T Offline
          T Offline
          The underdog
          wrote on last edited by
          #4

          I get the containment of the Table. So that works as it should But how to go on now? The underdog

          U 1 Reply Last reply
          0
          • T The underdog

            I get the containment of the Table. So that works as it should But how to go on now? The underdog

            U Offline
            U Offline
            Utku KAYA
            wrote on last edited by
            #5

            If your OleDb code work then as you did last time, comboBox1.DataSource = table; combobox1.DisplayMember = columnNameYouWantToListInTheTable as string; should work. I dont know what the column name is. Try some possibilities. Sorry for incomplete help.

            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