------ 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 ChaudharyRank #1,379 · 1.2K reputationPosted Aug 3, 2012, 5:36 AM EDT
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.
Rodney Johnson78 reputationPosted Aug 3, 2012, 5:51 AM EDT
Sudhakar ChaudharyRank #1,379 · 1.2K reputationPosted Aug 3, 2012, 6:08 AM EDT