Increase Connection Timeout


Author
Message
Kenneth Langley
Kenneth Langley
StrataFrame Novice (84 reputation)StrataFrame Novice (84 reputation)StrataFrame Novice (84 reputation)StrataFrame Novice (84 reputation)StrataFrame Novice (84 reputation)StrataFrame Novice (84 reputation)StrataFrame Novice (84 reputation)StrataFrame Novice (84 reputation)StrataFrame Novice (84 reputation)
Group: StrataFrame Users
Posts: 26, Visits: 1.5K
More detail, we have a varbinary(max) field with binary data. This field size could be in the megabytes range. It appears that when moving the binary data is when the timeout occurs. Any more ideas ?
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Wow, I remember when a T1 was a fast connection! BigGrin



You might try just writing your own FillByPrimaryKey, put it your base BO, so all your BOs use it and none of the client code needs changing. You could then reference a property that you can set to increase the timeout. The FillByPrimaryKey code is easy, especially if you only need to overload one of them. Then you could set the timeout on the SqlCommand object:



Public Overloads Sub FillByPrimaryKey(key As Integer)

  Dim sql As String

  sql = String.Format("Select * From {0} Where {1} = @key", Me.TableName, Me.PrimaryKeyField)

  Using cmd As New SqlCommand()

    cmd.CommandText = sql

    cmd.Parameters.AddWithValue("@key",key).SqlDbType = SqlDbType.int

    cmd.CommandTimeOut = 60 ' Time out in seconds...pull from a global property or something

    Me.FillDataTable(cmd)

  End Using

End Sub




There may be a way to set the timeout for a BusinessLayer also, but this might work (haven't tried it myself).
Kenneth Langley
Kenneth Langley
StrataFrame Novice (84 reputation)StrataFrame Novice (84 reputation)StrataFrame Novice (84 reputation)StrataFrame Novice (84 reputation)StrataFrame Novice (84 reputation)StrataFrame Novice (84 reputation)StrataFrame Novice (84 reputation)StrataFrame Novice (84 reputation)StrataFrame Novice (84 reputation)
Group: StrataFrame Users
Posts: 26, Visits: 1.5K
I guess I should have said that the clients that are having the timeout issue are on a T1 line remote from the SQL server and that the line is used by several users. This timeout occurs  based on the T1 load at the time. Hope this helps explain a little better.
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I'm not sure how to change the time out, but I'm suspicious that something else is going on. I've never had a time out except when I had a connection problem. I.e. only if I couldn't access the server....in which case more time isn't going to help. You many have already done this, but I'd check that your connection string is OK, that you have access to the server, that sort of thing. Most of my users are remote, sometimes with horrible connections. Rarely is there a time out, especially on a FillByPrimaryKey, which usually is using a clustered index.



I'll be interested to know about how to set the timeout too! BigGrin
Kenneth Langley
Kenneth Langley
StrataFrame Novice (84 reputation)StrataFrame Novice (84 reputation)StrataFrame Novice (84 reputation)StrataFrame Novice (84 reputation)StrataFrame Novice (84 reputation)StrataFrame Novice (84 reputation)StrataFrame Novice (84 reputation)StrataFrame Novice (84 reputation)StrataFrame Novice (84 reputation)
Group: StrataFrame Users
Posts: 26, Visits: 1.5K
How do you set the sql command timeout on SF built in calls such as FillbyPrimaryKey. We are using these commands and getting a timeout. Is there a global setting that SF will use for the SF system generated calls?
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Thanks.  Took me a minute to make the right connection from the command to the BO.  Here is my revised code:

ADUserBO mADUser = new ADUserBO();
String mPartNum = String.Empty;
if (PartNumCBE.SelectedValue != null)
{
    mPartNum = (
String)PartNumCBE.SelectedValue;
}
SqlCommand cmd = new SqlCommand("spx_GetRunningInventory_FinishedGoods");
cmd.CommandTimeout = 0;
cmd.Parameters.AddWithValue(
"@partnum", mPartNum).SqlDbType = SqlDbType.VarChar;
cmd.Parameters.AddWithValue(
"@div", mADUser.LocationIndex).SqlDbType = SqlDbType.Int;
cmd.Parameters.AddWithValue(
"@invdate", InvDateDE.DateTime.ToShortDateString()).SqlDbType = SqlDbType.VarChar;
cmd.CommandType =
CommandType.StoredProcedure;
rawMaterialValuationBO1.FillDataTable(cmd);
gridView1.Columns[
"CurrQty"].FilterInfo = new DevExpress.XtraGrid.Columns.ColumnFilterInfo("CurrQty > 0");
gridView1.ApplyColumnsFilter();

Works great!  Thanks a bunch.  Oh...and the wait window...awefully nice feature!!

Now, I just need to work on getting that sproc to run faster than 90 seconds.  It has several nested CASE statements that I think are gumming up the works.  Not too sure how to simplify those conversions that are going on.

Happy Friday!
Bill


Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
If the command timeout can be set, how do I do that from the BO?

Through a command:

'-- Establish Locals
Dim cmd As New SqlCommand("MyStoredSproc")

'-- Never time out
cmd.CommandTimeout = 0

'-- Set the parms
cmd.Parameters.AddWithValue("@Parm1", 1).SqlDbType = SqlDbType.Int

'-- Set the command type
cmd.CommandType = CommandType.StoredProcedure

'-- Execute the command
Me.ExecuteNonQuery(cmd)


Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Thanks Paul and Edhy!!

I am still using SQL Server 2000...I will see if I can find a corresponding configuration for setting the timeout.

Here is my code that I use for retrieving the data:

String mPartNum = String.Empty;
if (PartNumCBE.SelectedValue != null)
{
    mPartNum = (
String)PartNumCBE.SelectedValue;
}
SqlParameter mItemCode = new SqlParameter("@partnum", mPartNum);
ADUserBO mADUser = new ADUserBO();
SqlParameter mDiv = new SqlParameter("@div", mADUser.LocationIndex);
SqlParameter mInvDate = new SqlParameter("@invdate", InvDateDE.DateTime.ToShortDateString());
rawMaterialValuationBO1.FillByStoredProcedure(
"spx_GetRunningInventory_FinishedGoods", mItemCode, mDiv, mInvDate);
gridView1.Columns[
"CurrQty"].FilterInfo = new DevExpress.XtraGrid.Columns.ColumnFilterInfo("CurrQty > 0");
gridView1.ApplyColumnsFilter();

If the command timeout can be set, how do I do that from the BO?

Thanks,
Bill


Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Yeah, Paul nailed it on the last post.  The most common timeout that is overlooked is on the command itself.  You can set the connection timeout until you are blue in the face...but if you don't set the command time out it can still timeout on you.  So if you set the command timeout you should be good to go! Smile
Paul Chase
Paul Chase
Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K
Bill,

I thought that I had found where to set it on a per query basis, I set it server wide to deal with an issue with E-connect for Great Plains, to set in on a per query basis simply set the commandtimeout property of the Sql Command.

Dim loCommand As New SqlCommand()

loCommand.CommandTimeout = 150

'-- Build the Query

loCommand.CommandText = "SELECT * FROM WHATEVER"


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search