NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Changing default SQL database within Teststand

Solved!
Go to solution

I am designing a "universal" test system for a variety of my company's products.

The test results are supposed to be logged to a MS SQL (2008) database. I've created two databases for two different products. Let's call them OneTestDB and TwoTestDB for now.

No problems so far. Now, I want to use a user, TestLogin, to write the test data to the both of my databases, however, TestLogin can seems only to be able to write to the DB set as default.

I could solve the problem by using different users, but since I want it to be possible for the same user to test different products, I would prefer to avoid this.

After searching the net for an answer I found that that what I'm trying to do is done by the query "EXEC sp_defaultdb 'USER', 'DATABASE'. (Would USE {DATABASE} work as well?)

The database name is given at runtime. (DATABASE = StationGlobals.ProductName + "TestDB")

 

Here is my question: how , and where, to put that code into Teststand (2010 SP1) so that I can change the database to which I want to save the test results?

I have been trying to use the database tools given in Teststand, but obviously I am not doing it the right way.

0 Kudos
Message 1 of 2
(3,068 Views)
Solution
Accepted by topic author _KL_

I managed to fix it myself.

The solution was the following SQL statement "EXEC sp_defaultdb 'TestLogin', '" + StationGlobals.ProductName + "TestDB'"

If someone has a better idea how to solve the issue, feel free to enlighten me.

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