moose2004 Posted May 25, 2010 Share Posted May 25, 2010 What i am doing is pushing data from DAQFactory to a MYSQL DB (this works) but i have allowed the ability for users to select whatever channels they want to add at anytime. So i need to do a comparison against the newly added channels to what DB table columns already exists. Here is what i have so far.... private handle = db.Open('dbtest', 'root', '') //DB Name, Username, Password private string sql private result sql = "SHOW COLUMNS FROM test" result = db.QueryToClass(handle, sql) ? result db.Clos(handle) This will return Objects(s) in the Command/Alert window. How did i get a handle on these Objects, to see if this is correct??? If there is an easier way of returning the DB table column names, please let me know!!! Thanks! Link to comment Share on other sites More sharing options...
AzeoTech Posted May 25, 2010 Share Posted May 25, 2010 querytoClass() can really only be used with the SELECT statement. All others have to use the db.Execute() function, but that function doesn't return anything, so can't be used with SHOW calls. If you do queryToClass() it returns an object with all the fields. It also returns two extra member variables: fieldnames, which is a string array with the names of the fields returned, and RecordCount which is the total number of records returned. You can thus do something like: private string sql = "select * from table limit 1" private result = db.queryToClass(handle, sql) ? result.FieldNames Note that using "limit 1" is not really the most efficient way to return just one record as the database will often do the entire query and then limit. If your database is small its probably not an issue. Link to comment Share on other sites More sharing options...
moose2004 Posted May 25, 2010 Author Share Posted May 25, 2010 That was what i needed....It Works!!! Thanks, Zane Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.