Hi, i'm using .Net framework 1.0 & MS Access 2003 database. Using ODBC connection, I want to list all tables in ms access database in a listbox....Please help me.... very urgent...

Here is an example in C#

private void SetTableList(string factoryName)
    {
      try
      {
        DbProviderFactory factory = DbProviderFactories.GetFactory(factoryName);

        using (DbConnection connection =
                    factory.CreateConnection())
        {
          connection.ConnectionString = _conn.ConnectionString;
          connection.Open();
          _dtTables = connection.GetSchema("Tables");
          _dtColumns = connection.GetSchema("Columns");

          List<string> Sql = new List<string>();
          for (int i1 = 0; i1 < _dtTables.Rows.Count; i1++)
          {
            string tableName = (string)_dtTables.Rows[i1]["TABLE_NAME"];

            try
            {
              string tableType = (string)_dtTables.Rows[i1]["TABLE_TYPE"];
              if ((tableType.ToLower().Contains("system")) || (tableType.ToLower().Equals("access table")))
                continue;
            }
            catch { }

            Sql.Add(tableName);
          }

          Sql.Sort();

          listBoxControlTables.Items.BeginUpdate();
          listBoxControlTables.Items.Clear();

          for (int i1 = 0; i1 < Sql.Count; i1++)
          {
            listBoxControlTables.Items.Add(Sql[i1]);
          }
          listBoxControlTables.Items.EndUpdate();
        }

        if (listBoxControlTables.Items.Count > 0)
          listBoxControlTables.SelectedIndex = 0;
      }
      catch { }
    }

Calling it:

SetTableList(@"System.Data.Odbc");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.