Forums: [SOLVED] Timeouts - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

[SOLVED] Timeouts Rate Topic: -----

#1 User is offline   Frank I 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 4
  • Joined: 17-January 18

Posted 23 January 2018 - 04:01 PM

We have a large data set, and some complex SQL queries run for up to 90 seconds. I can run these queries just fine in management studio, but get timeouts after 30 seconds when running through the ASPRunner.net generated application (both from the local host and from the web server). Where can I adjust the connection string to extend the timeout setting?

Thanks
Frank
0

#2 User is offline   Frank I 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 4
  • Joined: 17-January 18

Posted 20 February 2018 - 02:41 PM

This was solved by placing a timeout into the connections.cs file in the Source directory under the ASPRunner.NET application (not the output of the application I was building, but the ASPRunner.NET application itself in Program Files)

cmd.CommandTimeout = 120;

Below is where I placed the statement:
if (GlobalVars.dDebug)
MVCFunctions.EchoToOutput(sql.ToString() + "<br />");

GlobalVars.strLastSQL = sql;
DbCommand cmd = null;
DbCommand initCmd = null;
try {

DbConnection connection = connectionsPool.FreeConnection;
if (connection.State != System.Data.ConnectionState.Open)
{
connection.Open();
if( initializingSQL != null )
{
initCmd = GetCommand();
initCmd.Connection = connection;
initCmd.CommandText = initializingSQL;
initCmd.Prepare();
initCmd.ExecuteNonQuery();
}
}
cmd = GetCommand();
cmd.Connection = connection;
//Adding SQL timeout
cmd.CommandTimeout = 120;
cmd.CommandText = sql;
cmd.Prepare();

string commandStr = sql.ToLower().Substring(0, 6);
string [] stopCommandList = {"insert", "update", "delete", "create", "drop", "rename", "alter"};
if (stopCommandList.Any(x => commandStr.Substring(0, x.Length) == x))
{
cmd.ExecuteNonQuery();
CalculateLastInsertedId(commandStr, cmd);
cmd.Connection.Close();
return null;
}
else
{
RunnerDBReader rdr = cmd.ExecuteReader();
rdr.Connection = cmd.Connection;
return new QueryResult(this, rdr);
}
0

#3 User is offline   Pete K 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 229
  • Joined: 05-February 16

Posted 20 February 2018 - 07:31 PM

Thanks for sharing your solution, Frank. Good information to know.


----------------------------------------------------------
Pete K.
Web Developer
Fayette County Public Schools | Lexington, Kentucky, USA
0

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked