Hello,
I am testing out SQL Connection with Telerik code . It's simple function to fetch records from SQL server.
Here is code snippet. When I run telerik test with Coded Step ,It's failing on ExecuteReader() statement with error
"Exception thrown executing coded step: 'Tear Down'.
Incorrect syntax near ')'."
Test compiled fine and there is no syntax error on the output.
[CodedStep(@"Tear Down")]
public void DeleteCreatedAcct_TearDown()
{
SqlConnection conn ;
SqlCommand sqlQuery;
SqlDataReader sqlDataSet;
string sqlQueryString;
conn = new SqlConnection("data source=DBTEST;initial catalog=DBName ;persist security info=True;user id=usrid;password=pwd");
//Open SQL Connection
conn.Open();
Console.WriteLine("DB Name");
Console.WriteLine(conn.Database);
//Create SQL Command
sqlQuery = conn.CreateCommand();
sqlQueryString = "SELECT AcctId FROM DBtable where UpdatedBy ='Automation Tester')";
Console.WriteLine(sqlQueryString);
//Create SQL query to fetch records
sqlQuery = new SqlCommand(sqlQueryString , conn);
Console.WriteLine("After sqlQuery.CommandText =sqlQueryString" );
Console.WriteLine("SQL Parameters" + sqlQuery.Parameters);
Console.WriteLine("BEFORE EXECUTE QUERY");
sqlDataSet = sqlQuery.ExecuteReader(); <<failing at this line.
Console.WriteLine("After sqlDataSet = sqlQuery.ExecuteReader();" );
while (sqlDataSet.Read())
{
Console.WriteLine("Account ID: " + sqlDataSet["AcctId"] );
}
}
Thanks,
-
Padmashree