title: How to read column names using SQL
body: <p>I am trying to read the column names from a table using a jet SQL query. The data table is held in ms-access in 2002-2003 compatibility mode. I have tried a couple of variations for the query but I can't seem to get the correct syntax.</p>
  
  <pre><code>DatabaseConnection("SELECT Column_name" &amp; " FROM " &amp; tablename, "Read Recordset")
  
  DatabaseConnection("select column_name from information_schema.columns where table_name = tabDataHourly", "read Recordset")
  </code></pre>
  
  <p>I have a function that runs the database connections:
       Public Function DatabaseConnection(ByVal Query As String, ByVal Task As String) As String
          'On Error GoTo Err</p>
  
  <pre><code>    cnnOLEDB = New OleDbConnection
      cnnOLEDB.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &amp; DataDirectoryName &amp; DatabaseFileName
      cnnOLEDB.Open()
  
      cmdOLEDB.Connection = cnnOLEDB
      cmdOLEDB.CommandText = Query
  
      Select Case Task
          Case "Read Recordset"
              rdrOLEDB = cmdOLEDB.ExecuteReader()
              DatabaseConnection = "Read Recordset"
          Case "Read Scalar"
              DatabaseConnection = cmdOLEDB.ExecuteScalar
          Case "Non-Query"
              cmdOLEDB.ExecuteNonQuery()
              DatabaseConnection = "Non-Query"
      End Select
  
      Exit Function
  Err:
      MsgBox("Database connection error.")
      DatabaseConnection = "Error"
  
  
  End Function
  </code></pre>
  
  <p>Any help would be greatly appreciated.</p>