Home All Groups Group Topic Archive Search About
Author
17 Mar 2006 7:28 PM
Neo
is there any reason why a sql command will execute in sql server and not in
Vb.Net?
It takes about 1.5 minutes to execute.. Would the timeout have anything to
do with it? If so how do I increase it?

Author
17 Mar 2006 7:37 PM
John Scragg
You can use the CommandTimeout property of your command object.  The default
timeout iirc is 30 seconds.  So you would indeed timeout on a proc that ran
for a minute and a half.

HTH,

John

Show quote
"Neo" wrote:

> is there any reason why a sql command will execute in sql server and not in
> Vb.Net?
> It takes about 1.5 minutes to execute.. Would the timeout have anything to
> do with it? If so how do I increase it?
Author
17 Mar 2006 8:01 PM
Neo
Is there any way that i would be able to set the timeout in the connection
string? Because I don't know how to load a datagrid after executeNonQuery().
Only after filling a dataAdapter.. which is what I usually do for Select
statements.

Show quote
"John Scragg" wrote:

> You can use the CommandTimeout property of your command object.  The default
> timeout iirc is 30 seconds.  So you would indeed timeout on a proc that ran
> for a minute and a half.
>
> HTH,
>
> John
>
> "Neo" wrote:
>
> > is there any reason why a sql command will execute in sql server and not in
> > Vb.Net?
> > It takes about 1.5 minutes to execute.. Would the timeout have anything to
> > do with it? If so how do I increase it?
Author
17 Mar 2006 8:46 PM
Mike Labosh
> Is there any way that i would be able to set the timeout in the connection
> string? Because I don't know how to load a datagrid after
> executeNonQuery().
> Only after filling a dataAdapter.. which is what I usually do for Select
> statements.

The DataAdapter has a SelectCommand property which has a CommandTimeout
property:

Dim cnstr As String = "your connection string"
Dim cn As New SqlConnection(cnstr);

' This configures how long to wait to do cn.Open()
cn.ConnectionTimeout = 60

Dim ds As New DataSet()
Dim da As New SqlDataAdapter("SELECT ...")

' This configures how long to wait for the da.Fill(ds)
da.SelectCommand.CommandTimeout = 120

' Internally, this secretly uses a SqlDataReader to get the data
da.Fill(ds)

While we're at it, if you use the visual designer tools to build your
DataSet or DataAdapter, depending on the options you select, the DataAdapter
can have up to four different Commands attached to it.  These are exposed to
you as the SelectCommand, InsertCommand, DeleteCommand and UpdateCommand
properties

Since this is more of a VB.NET / ADO.NET question than it is a SQL Server
question, you will probably get better details by posting in
microsoft.public.dotnet.languages.vb.data
--


Peace & happy computing,

Mike Labosh, MCSD MCT
Owner, vbSensei.Com

"Escriba coda ergo sum." -- vbSensei
Author
20 Mar 2006 2:50 PM
Neo
i actually used the datatable to fill it as opposed to the dataset. Do you
know which is faster? Any time i can cut will be useful


Show quote
"Mike Labosh" wrote:

> > Is there any way that i would be able to set the timeout in the connection
> > string? Because I don't know how to load a datagrid after
> > executeNonQuery().
> > Only after filling a dataAdapter.. which is what I usually do for Select
> > statements.
>
> The DataAdapter has a SelectCommand property which has a CommandTimeout
> property:
>
> Dim cnstr As String = "your connection string"
> Dim cn As New SqlConnection(cnstr);
>
> ' This configures how long to wait to do cn.Open()
> cn.ConnectionTimeout = 60
>
> Dim ds As New DataSet()
> Dim da As New SqlDataAdapter("SELECT ...")
>
> ' This configures how long to wait for the da.Fill(ds)
> da.SelectCommand.CommandTimeout = 120
>
> ' Internally, this secretly uses a SqlDataReader to get the data
> da.Fill(ds)
>
> While we're at it, if you use the visual designer tools to build your
> DataSet or DataAdapter, depending on the options you select, the DataAdapter
> can have up to four different Commands attached to it.  These are exposed to
> you as the SelectCommand, InsertCommand, DeleteCommand and UpdateCommand
> properties
>
> Since this is more of a VB.NET / ADO.NET question than it is a SQL Server
> question, you will probably get better details by posting in
> microsoft.public.dotnet.languages.vb.data
> --
>
>
> Peace & happy computing,
>
> Mike Labosh, MCSD MCT
> Owner, vbSensei.Com
>
> "Escriba coda ergo sum." -- vbSensei
>
>
>
Author
20 Mar 2006 2:59 PM
Neo
Thank You!!
Just the simple approach of a dataAdapter was what i needed to use. The
timeout property i didn't know about.
you rock!

Show quote
"Mike Labosh" wrote:

> > Is there any way that i would be able to set the timeout in the connection
> > string? Because I don't know how to load a datagrid after
> > executeNonQuery().
> > Only after filling a dataAdapter.. which is what I usually do for Select
> > statements.
>
> The DataAdapter has a SelectCommand property which has a CommandTimeout
> property:
>
> Dim cnstr As String = "your connection string"
> Dim cn As New SqlConnection(cnstr);
>
> ' This configures how long to wait to do cn.Open()
> cn.ConnectionTimeout = 60
>
> Dim ds As New DataSet()
> Dim da As New SqlDataAdapter("SELECT ...")
>
> ' This configures how long to wait for the da.Fill(ds)
> da.SelectCommand.CommandTimeout = 120
>
> ' Internally, this secretly uses a SqlDataReader to get the data
> da.Fill(ds)
>
> While we're at it, if you use the visual designer tools to build your
> DataSet or DataAdapter, depending on the options you select, the DataAdapter
> can have up to four different Commands attached to it.  These are exposed to
> you as the SelectCommand, InsertCommand, DeleteCommand and UpdateCommand
> properties
>
> Since this is more of a VB.NET / ADO.NET question than it is a SQL Server
> question, you will probably get better details by posting in
> microsoft.public.dotnet.languages.vb.data
> --
>
>
> Peace & happy computing,
>
> Mike Labosh, MCSD MCT
> Owner, vbSensei.Com
>
> "Escriba coda ergo sum." -- vbSensei
>
>
>

AddThis Social Bookmark Button