Hi We are using EnterpriseLibrary to connect to database. I want run 2 or more SPs on same connection. I want set the context and run multiple SPs in the same session.
But when the first SP the the connection is getting closed.
db = DatabaseFactory.CreateDatabase();
DbCommand selectCommand = db.GetStoredProcCommand("dbo.usp_set_session_context");
db.ExecuteReader(selectCommand);
DbCommand selectCommand1 = db.GetStoredProcCommand("dbo.usp_get_session_context");
using (IDataReader dataReader = db.ExecuteReader(selectCommand1))
{
while (dataReader.Read())
{
var data = dataReader["LoginUserAccountName"].ToString();
}
}
I did tried open a connection and tried to use it but its not working as well
//using (var con = db.CreateConnection())
//{
// con.Open();
// DbCommand selectCommand = db.GetStoredProcCommand("dbo.usp_set_session_context");
// db.ExecuteReader(selectCommand);
// DbCommand selectCommand1 = db.GetStoredProcCommand("dbo.usp_get_session_context");
// using (IDataReader dataReader = db.ExecuteReader(selectCommand1))
// {
// while (dataReader.Read())
// {
// var data = dataReader["LoginUserAccountName"].ToString();
//
//
// }
// }
//}
How can I keep my connection alive? I don’t want to use the transition scopes.