Forum Discussion

JonoW's avatar
JonoW
Occasional Contributor
13 years ago

File DSN help, please.

Hi,



I've been using a User or System DSN for my DB connection in tests, so far and it's been working great.

I can't create a user DSN on other machines that will be running the tests via TestExecute, so I'd like to use a File DSN, then check that into the source repository and then everyone should be able to use it; they'll all have the same drivers that are required.



My question is - HOW do I use a File DSN in the connection after I've created it?



var Qry, FoundCR;

// Create a query

Qry = ADO["CreateADOQuery"]();

// Specify a Connection string - currently uses SystemDSN

Qry["ConnectionString"] = "Provider=MSDASQL;Persist Security Info=False;Data Source=Recipes";

// Specify the SQL expression - Cluster Recipe Name passed in from outside

Qry["SQL"] = "Select max(ID) as ID from ClusterRecipes where Name = '" + CRName + "'";

// Execute the Query

Qry["Open"]();



This worked fine... but adding ".dsn" onto the end of Recipes doesn't work.

I'm not sure where the .dsn file should reside. I've put it in the scripts folder, and pointed ODBC data sources at it ... but still no joy.



Is anyone able to help me with this? Hopefully it's something simple. The Connection Test works fine from the ODBC manager, so the dsn itself seems ok.



It's all running on 32 bit O/S too...

2 Replies

  • Hi Jono,



    I believe the question is more related to connection strings and data providers than to TestComplete. I recommend that you try finding a connection string which allows specifying the needed DSN on the following web site:


    http://connectionstrings.com
  • JonoW's avatar
    JonoW
    Occasional Contributor
    Thanks Allen,



    The solution was to do something like this:



    var DSN = "FILEDSN=MyFileDsn.dsn";  // MyFileDsn.dsn resides in my script folder - otherwise include the path to it e.g. =c:\MyFileDsn.dsn



    var Qry = ADO["CreateADOQuery"]();

    Qry["ConnectionString"] = DSN;

    Qry["SQL"] = "select blah blah blah from something";

    Qry["Open"]();





    But basically, I just had to point the Connection string at the DSN file... should've thought about that in the first place.