08-11-2009 01:02 AM
I am using DIAdem 11.0 to view data from my MySQl database. I tried with the Datastores SQL option to connect using ODBC Provider to MySQL. I am wondering because the connection is established and it is listing all the tables, but no data.
Then I tried using the mySQL_example.vbs which I got from the website, and it is working with listing of tables with data. But here I am facing a problem that the select query is giving error when channel names(no) exceeds 255 characters, since the 'SQL_ColList' size is 255 only, for I am having around 625 channels to read.
Please suggest an option to view all the channel data either through Data stores or by running the VB script.
Thanks
Cinil Abraham
08-11-2009 10:55 PM
Hi Cinil,
You have 2 choices. You can stick with the DIAdem "SQL_...()" functions that are based on ODBC, in which case you will need multiple queries to return more than 255 columns of data, or you can switch to using the ADO approach and query all your columns at once.
Since you already have a DSN, which is required for the "SQL_...()" functions, you can use the following ADO connection string:
ConnectionStr = "DSN=MyDataSourceName;UID=MyUserID;PWD=MyPassword;"
Here's an example of the ADO approach:
' Connect to the data base
Set ADO = CreateObject("ADODB.Connection")
ADO.Open ConnectionStr
' Execute the query and import the resulting data records into a VBScript variable
Set RecordSet = ADO.Execute(QueryStr)
RowVals = RecordSet.GetRows()
' Send the resulting data records from the query to new channels in the Data Portal
Call DataDelAll
Call GroupCreate(Table)
Call GroupDefaultSet(GroupCount)
Channels = Split(ColStr, ",")
For z = 0 To UBound(Channels)
AsPos = InStr(UCase(Channels(z)), " AS ")
IF AsPos > 1 THEN Channels(z) = Trim(Mid(Channels(z), AsPos+1))
Channels(z) = "[" & GroupDefaultGet & "]/" & Channels(z)
Next ' z
Channels = ArrayToChannels(RowVals, Channels, 1)
' Disconnect from the database and output the query used and any errors
ADO.Close
Brad Turpin
DIAdem Product Support Engineer
National Instruments
08-12-2009 12:36 AM
Hi Brad,
Thanks for the suggestions. Anyway now I am able to view the data using the ADO approach and SQL functions. Also i am using tha 'SOL Wizard 102' for querying the desired channels with some modifications in the .SUD file and it seems interesting.
08-12-2009 12:38 AM
Hi Brad,
Thanks for the suggestions. Anyway now I am able to view the data using the ADO approach and SQL functions. Also i am using tha 'SOL Wizard 102' for querying the desired channels with some modifications in the .SUD file and it seems interesting.