NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing Variables in TestStand through LabView

Solved!
Go to solution

I have an error I am trying to set up an overwrite on the Database Options Callback. I am telling TestStand which database to write to. I am passing it a variable and I get an error. Below is a description of the error.

 

Here is the Statement I am using:

In the DatabaseOptions Callback I am using a statement to change which database the data is being stored.

 

I have a VI that passes a string which is the location of my database file I want to use. I have it stored as variable in StationGlobals called database (It is currently a String but I have tried executable and path also with the same error).

 

Parameters.DatabaseOptions.ConnectionString = StationGlobals.Database

 

StationGlobals.Database is set to

"\"Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=C:\\Users\\Public\\Documents\\\\National Instruments\\\\TestStand 4.2.1\\Components\\Models\\\\TestStand Results.mdb;\""

 

There has to be a problem with the variables because when I copy and paste what StationGlobals.Database in and use the following statement it works perfectly fine.

 

Parameters.DatabaseOptions.ConnectionString = "\"Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=C:\\Users\\Public\\Documents\\\\National Instruments\\\\TestStand 4.2.1\\Components\\Models\\\\TestStand Results.mdb;\""

 

The following is the error that I get:

 

Details:

An error occurred calling 'LogResults' in 'ITSDBLog' of 'zNI TestStand Database Logging'

An error occurred initializing a connection to a data link.

Connection String: "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=C:\Users\Public\Documents\\National Instruments\\TestStand 4.2.1\Components\Models\\TestStand Results.mdb;"

Description: [Microsoft][ODBC Driver Manager] Data source name too long

Number: -2147467259

NativeError: 0

SQLState: IM010

Reported by: Microsoft OLE DB Provider for ODBC Drivers

Source: TSDBLog

 

Error Code:

-2147467259; User-defined error code.

Possible System Error: Unspecified error

 

Location:

Step 'Log Results to Database' of sequence 'Log To Database' in 'Database.seq'

 

Please Help I can't find any solution to this question.

 

Thank you very much for any help

0 Kudos
Message 1 of 3
(3,148 Views)
Solution
Accepted by topic author JDASM

Once again, Expression Strings, has stumbled another programmer!

 

Parameters.DatabaseOptions.ConnectionString is not a string but an Expression String, and your assignment of a StationGlobals.Database ( just a string ) is causing this error.

 

Here is what I did to solve your issue:

 

1.) StationGlobals ( remove the leading "\" and trailing \"" from the Database string ) it should contain NO leading or trailing quotes

 

StationGlobals.Database = Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=C:\\Users\\Public\\Documents\\National Instruments\\TestStand 4.2.1\\Components\\Models\\TestStand Results.mdb.

 

2.) In Database Options Callback use the following expression to set the Data Source

 

Parameters.DatabaseOptions.ConnectionString= "StationGlobals.Database"

 

There are other alternatives as documented in this link.

 

http://zone.ni.com/devzone/cda/tut/p/id/4793

 

Good luck,

 

PH

0 Kudos
Message 2 of 3
(3,138 Views)

Thank you so much that was very helpful

 

It worked perfectly

0 Kudos
Message 3 of 3
(3,132 Views)