This is a migrated thread and some comments may be shown as answers.

Access datasource properties from code

3 Answers 102 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Alex Rak
Top achievements
Rank 2
Alex Rak asked on 27 Sep 2012, 07:32 PM
Hi,

I've seen the example of how to access SQL database from the code, which would work perfectly fine. One thing I don't like thought, is defining the connection string in the code. I'd rather have access to a connection string property of my datasource which is defined in the project. Is this currently possible?

Regards.

3 Answers, 1 is accepted

Sort by
0
Byron
Telerik team
answered on 02 Oct 2012, 11:09 PM
Hello Alex Rak,

Thanks for trying Test Studio. Using Test Studio Standalone, you can define a connection string property when binding your SQL data source. Afterward, you can access the database through the Data object in code. 

Kind regards,
Byron
the Telerik team
Are you enjoying Test Studio? We’d appreciate your vote in the ATI automation awards.
Vote now
0
Alex Rak
Top achievements
Rank 2
answered on 05 Oct 2012, 03:50 PM
Hi, Byron, thanks for getting back on this.

You're right, I could access the Data object to read the data. What I need is a direct call towards the database. Let's say I want to make a database insert from withing the coded step, or call a stored procedure with custom parameters. There's no way to do that other than creating my proper database connection in the coded step. What I don't want is to manage my connection strings in the code. I would rather access the connection string of a DataSource that's already defined in my project. Is this possible?

Regards.
0
Accepted
Byron
Telerik team
answered on 10 Oct 2012, 06:12 PM
Hello Alex,

There is a way to store and access the connection string outside the coded step using the Visual Studio Plugin: overriding the app.config file, which contains run-time configuration settings for the Visual Studio project, including connection strings. Our user guide discusses the code necessary to find, open, read, and parse this file.

Regards,
Byron
the Telerik team
Are you enjoying Test Studio? We’d appreciate your vote in the ATI automation awards.
Vote now
Tags
General Discussions
Asked by
Alex Rak
Top achievements
Rank 2
Answers by
Byron
Telerik team
Alex Rak
Top achievements
Rank 2
Share this question
or