Click or drag to resize

SqlHelperExecuteSqlCommand(String, String, IEnumerableString) Method

Framework to automate tests using Selenium WebDriver
Method is used for execution SQL query (select) and reading each column from row.

Namespace: Ocaramba.Helpers
Assembly: Ocaramba (in Ocaramba.dll) Version: 1.0.0+d8e789f8644d1a9b63485ad7914acf4f489f3ef9
Syntax
C#
public static Dictionary<string, string> ExecuteSqlCommand(
	string command,
	string connectionString,
	IEnumerable<string> columns
)
Request Example

Parameters

command  String
SQL query.
connectionString  String
Server, user, pass.
columns  IEnumerableString
Name of columns.

Return Value

DictionaryString, String
Dictionary of each column existed in raw.
Exceptions
ExceptionCondition
KeyNotFoundExceptionException when there is not given column in results from SQL query.
Example
How to use it:
C#
var connectionString = "User ID=sqluser;Password=sqluserpassword;server=servername;";
ICollection<string> column = new List<string>();
column.Add("NationalIDNumber");
column.Add("ContactID");
const string SqlQuery = "SELECT [NationalIDNumber] as " + column.ElementAt(0) + " , [ContactID] as " + column.ElementAt(1) + " from [AdventureWorks].[HumanResources].[Employee] where EmployeeID=1";
Dictionary<string, string> results = SqlHelper.ExecuteSqlCommand(command, GetConnectionString(server), column);
See Also