How to Access a SQL Database in Code
You can access an SQL database in a data driven test, as seen here. This is built-in functionality for Test Studio, but not for Telerik Testing Framework. This article demonstrates how to access a SQL database through code, which allows for greater flexibility. Also, writing into a database is only possible with a coded solution.
Add Assembly Reference
Use the System.Data.SqlClient API. You'll need to add an assembly reference to it, as seen here. This API is part of the System.Data assembly. This assembly is located, by default, in the following location (on a 64-bit Windows 7 machine with .NET 4.0):
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\Profile\Client\System.Data.dll
If a reference to System.Data 2.0 already exists, remove it add it again from the above directory for the 4.0 version.
Ensure you add the using or Imports statement to the top of the code-behind file. Click the View Class button, scroll to the top of the code, and add this line:
Sample Code
Here we've create a SQL database named myFirstDB. This database contains a table named Table_1. This table contains a column named City.
Read from SQL Database
Write into SQL Database
Note: This code won't run without modification. The database, table, and column in the original code won't exist in your environment.