------ C# code in the DBHelper Class ----------------------------
internal static DataTable dataCommand(string command)
{
SqlConnection sqlConn = ConnectToDatabase();
IDbTransaction transaction = sqlConn.BeginTransaction();
DataTable dt = new DataTable();
try
{
Database db = DatabaseFactory.CreateDatabase("MyDB");
SqlCommand com = new SqlCommand();
com.CommandText = command;
dt = db.ExecuteDataSet(com).Tables[0];
transaction.Commit();
}
catch
{
transaction.Rollback();
throw;
}
finally
{
if (sqlConn.State == ConnectionState.Open) sqlConn.Close();
}
return dt;
}
internal static SqlConnection ConnectToDatabase()
{
SqlConnection sqlConn = new SqlConnection();
sqlConn.ConnectionString = ConfigurationManager.ConnectionStrings["MyDB"].ToString();
sqlConn.Open();
return sqlConn;
}
------------------------- End of Code -----------------------------------
------------------------App Config connection string -----------------
User ID = MyUserName;Password = MyPassword;connect timeout=180;"
providerName="System.Data.SqlClient" />
------------- End of connection string -------------------------------------
When I break at the SQLConnection I can see the timeout is set to 180 but it continually fails.
Suggestions?
Rod
Sudhakar ChaudharyPosted Aug 3, 2012, 9:36 AM
The Connection Timeout in the ConnectionString only controls the timeout for the connection. If you need to increase the wait time on your Commands, use the CommandTimeout property of SqlCommand.
Sudhakar ChaudharyPosted Aug 3, 2012, 10:08 AM
Rodney JohnsonPosted Aug 3, 2012, 9:51 AM