1

I'm trying to get the list of field names for a given table, to turn them into a string which I can to post back as a variable to another function.

I've Googled loads of stuff regarding GetSchemaTable but all I seem to be able to output are field parameters, but not the actual value of these parameters (ie ColumnName, which is the one I actually want!)

Found this page; What is the SQL command to return the field names of a table?

But all the queries on there give me an error "You do not have access to Table 'Columns'"

I feel sure this is pretty simple, can someone give me a little function that will simply give me

fieldNames = "fieldName1, fieldName2, etc"

I am using a MySQL server and ODBC connections ASP.NET using VB.

Community
  • 1
  • 1
Jamie Hartnoll
  • 7,231
  • 13
  • 58
  • 97

1 Answers1

0

I don't know if this will work, but give it a try.

  1. Instantiate a OdbcCommand with something like select * from yourtable limit 0;
  2. Load a DataTable with the datareader returned from cmd.ExecuteReader.

     DataTable dt as new DataTable()  
     dt.Load(cmd.ExecuteReader())
    
  3. Now iterate through the columns of dt to find out what the column names are.

This is just and idea. Don't know if it will work or not.

Icarus
  • 63,293
  • 14
  • 100
  • 115
  • Sorry it's taken me forever to come back to this... but it works! Thanks. I've now decided what I was trying to do is a stupid idea mind you!! – Jamie Hartnoll Nov 28 '11 at 19:25