Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - How to set commandTimeout for ObjectDataSource (ASP.NET 2.0)?

 
Thread Tools Search this Thread
Old 04-04-2006, 10:56 AM   #1
Default How to set commandTimeout for ObjectDataSource (ASP.NET 2.0)?


HI all.

In my web site I have some ObjetDataSource. Its business object
property is set to my dataset I created in dataset designer (this
dataset has table adapter).

My question is: how can I set command timeout property for fill method
from this table adapter?

Thanks in advance,
Piotrek.



Piotrek
  Reply With Quote
Old 04-25-2006, 11:08 AM   #2
Piotrek
 
Posts: n/a
Default Re: How to set commandTimeout for ObjectDataSource (ASP.NET 2.0)?

Anybody?

  Reply With Quote
Old 04-25-2006, 04:19 PM   #3
jd
 
Posts: n/a
Default Re: How to set commandTimeout for ObjectDataSource (ASP.NET 2.0)?

The timeout is normally set in the connection string. I don't know if
there's another place to specify it. If you want to use the same
timeout everywhere in your program, then just set the timeout value
globally. If you want to use different timeouts in different places,
you can dynamically build the connection string (note, however, that
this may reduce the effectiveness of connection pooling).

Hope this helps...

-- jeff

  Reply With Quote
Old 04-26-2006, 07:35 AM   #4
Piotrek
 
Posts: n/a
Default Re: How to set commandTimeout for ObjectDataSource (ASP.NET 2.0)?

Thanks jd.

However, I don't want to set Connection timeout but Command timeout. In
connection string only Connection timeout can be set.

Piotrek

  Reply With Quote
Old 04-26-2006, 10:17 PM   #5
jd
 
Posts: n/a
Default Re: How to set commandTimeout for ObjectDataSource (ASP.NET 2.0)?

How about setting the CommandTimeout property?

-- jeff

  Reply With Quote
Old 04-27-2006, 07:54 AM   #6
Piotrek
 
Posts: n/a
Default Re: How to set commandTimeout for ObjectDataSource (ASP.NET 2.0)?

Jd, that's exaclty what I want to do.

Just tell me, where I can find this CommandTimeout property (remember,
that I use auto generated table adapters).

Piotrek

  Reply With Quote
Old 04-27-2006, 12:12 PM   #7
Kevin Spencer
 
Posts: n/a
Default Re: How to set commandTimeout for ObjectDataSource (ASP.NET 2.0)?

It's fine to use autogenerated code, but at some point you need to tweak it.
In this case, you have code that creates a TableAdapter. A TableAdapter is a
wrapper for a DataAdapter. The DataAdapter in the Table Adapter has 4
different Command objects associated with it, one each for inserting,
selecting, updating, and deleting. The Command object has the CommandTimeout
property which can be used to adjust this.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Piotrek" <> wrote in message
news: oups.com...
> Jd, that's exaclty what I want to do.
>
> Just tell me, where I can find this CommandTimeout property (remember,
> that I use auto generated table adapters).
>
> Piotrek
>



  Reply With Quote
Old 04-27-2006, 01:56 PM   #8
Juan T. Llibre
 
Posts: n/a
Default Re: How to set commandTimeout for ObjectDataSource (ASP.NET 2.0)?

You can't set it globally, so you must set it for each Command object.

The Command object has a CommandTimeout property you can set.

See examples at :
http://msdn.microsoft.com/library/de... outtopic.asp




Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Piotrek" <> wrote in message
news: oups.com...
> Jd, that's exaclty what I want to do.
>
> Just tell me, where I can find this CommandTimeout property (remember,
> that I use auto generated table adapters).
>
> Piotrek
>



  Reply With Quote
Old 04-27-2006, 03:40 PM   #9
Piotrek
 
Posts: n/a
Default Re: How to set commandTimeout for ObjectDataSource (ASP.NET 2.0)?

Thanks for all answers.

I created a partial class, in which there is a SelectCommandTimeout
property:
namespace DataSetPaymentsTableAdapters
{
public partial class P_RWI_PAYMENTS_SEARCHTableAdapter
{
public int SelectCommandTimeout
{
get
{
return (this._commandCollection[0].CommandTimeout);
}


set
{
for (int i = 0; i < this._commandCollection.Length;
i++)
{
if ((this._commandCollection[i] != null))
{

((System.Data.SqlClient.SqlCommand)(this._commandC ollection[i])).CommandTimeout
= value;
}
}
}
}


}
}

My solution compiles without errors, but I do not how to call this
newly created property from the page, on which I have my
ObjectDataSource.

I would like to do sth like that (e.g. in the Page_Load event):
P_RWI_PAYMENTS_SEARCHTableAdapter.SelectCommandTim eout = 180
but this TableAdapter is not seen in IntelliSense.

Piotrek

  Reply With Quote
Old 04-27-2006, 04:12 PM   #10
Juan T. Llibre
 
Posts: n/a
Default Re: How to set commandTimeout for ObjectDataSource (ASP.NET 2.0)?

re:
> I would like to do sth like that (e.g. in the Page_Load event):
> P_RWI_PAYMENTS_SEARCHTableAdapter.SelectCommandTim eout = 180
> but this TableAdapter is not seen in IntelliSense.


It's simpler to set the Timeout in code :

<DataObjectMethod(DataObjectMethodType.Delete)> _
Public Shared Function DeleteEmployee(EID As Integer) As Boolean

If Not _initialized Then Initialize()

Dim conn As SqlConnection = New SqlConnection(_connectionString)
Dim cmd As SqlCommand = New SqlCommand("DELETE FROM E WHERE EID = @EmployeeID", conn)
cmd.CommandTimeout = 20
cmd.Parameters.Add("@EmployeeID", SqlDbType.Int).Value = EID

Try
conn.Open()

If cmd.ExecuteNonQuery() <> 0 Then _
Return False
Catch e As SqlException
' Handle exception.
Finally
conn.Close()
End Try

Return True
End Function



Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Piotrek" <> wrote in message
news: oups.com...
> Thanks for all answers.
>
> I created a partial class, in which there is a SelectCommandTimeout
> property:
> namespace DataSetPaymentsTableAdapters
> {
> public partial class P_RWI_PAYMENTS_SEARCHTableAdapter
> {
> public int SelectCommandTimeout
> {
> get
> {
> return (this._commandCollection[0].CommandTimeout);
> }
>
>
> set
> {
> for (int i = 0; i < this._commandCollection.Length;
> i++)
> {
> if ((this._commandCollection[i] != null))
> {
>
> ((System.Data.SqlClient.SqlCommand)(this._commandC ollection[i])).CommandTimeout
> = value;
> }
> }
> }
> }
>
>
> }
> }
>
> My solution compiles without errors, but I do not how to call this
> newly created property from the page, on which I have my
> ObjectDataSource.
>
> I would like to do sth like that (e.g. in the Page_Load event):
> P_RWI_PAYMENTS_SEARCHTableAdapter.SelectCommandTim eout = 180
> but this TableAdapter is not seen in IntelliSense.
>
> Piotrek
>



  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump