I'm running into an issue when I try to run a simple Selenium script which has field (SSN), and on every new run of the script SSN need to has bigger value (+1). Is it possible Selenium to connect with SQL Server database and check the SSN value from there, and what is the code to connect Selenium with SQL Server database? I am using Selenium with C#. Many Thanks.
public static int SSN_DB(IWebDriver session, string connString) {
//creating a db connection connection
var DBConnection = new SqlConnection(connString);
DBConnection.Open();
// Can execute a query or store procedure
var MemTable = new SqlCommand();
MemTable.CommandText = "Select top 1 SSN from dbo.member order by EMPL desc";
MemTable.Connection = DBConnection;
var dr = MemTable.ExecuteReader();
var Memberid = 0;
while (dr.Read()) {
Memberid = dr.GetInt32(0);
Console.WriteLine(Memberid);
}
return Memberid;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.