Timeout Expired Error 
Author Message
 Timeout Expired Error

I'm using Visual Basic 6.0 and SQL 7.0.  In my programs I connect to
my SQL database two different ways.  When ever I have to display data
in a datagrid or datalist then I use an ADO data control to establish
the connection.  If I dont' need to display the data in one of the
data bound controls then I use the following code to establish my
connection:

Private Sub Command1_Click()

Dim varADO As New ADODB.Connection
Dim adoRecordset As New ADODB.Recordset

varADO.Open ("Provider=SQLOLEDB.1;Persist Security Info=False;User    
ID=sa;Initial Catalog=GB_Database;Data Source=gbs01")

adoRecordset.Open "select * from stored_work_orders where workorder =
" & Chr(39) & txtWorkOrder.Text & Chr(39), varADO, adOpenStatic,
adLockOptimistic

Text1.Text = adoRecordset.Fields(0)

Set adoRecordset = Nothing
Set varADO = Nothing

Exit Sub

I use this code to make a connection several times in each program.
About 10 percent of the time when the program tries to open the
database it freezes for about 10 seconds and then a message pops up
saying "Timeout Expired".  As soon as I say OK to the message and try
again it seems to work.  I could bypass that error, but I still have
the problem of the delay.

As you can see in my code I don't close the recordset or the
connection before I set it to nothing.  Do I need to close it first,
and then set it to nothing, or does it automatically close when I set
it to nothing?

Should I establish a connection to the database when the program opens
and then leave that connection open until the program closes?

Should I establish my connection using the DSN on each local machine?

I know SQL is a powerful database program and should have no problem
supporting my appliations, but this timeout error is killing me.  Any
help you can give would be greatly appreciated!!!!!!



Mon, 22 Dec 2003 23:00:59 GMT  
 Timeout Expired Error
I had a similar problem, and what I found was that even though I don't use
ODBC, I had to set up an ODBC connection for the SQL server I was trying to
connect to. What was happening to me was that the default connection that
ADO was trying to use was named pipes and my server doesn't listen to the
named pipes. My server only works on TCP/IP, so as soon as I set up a system
DSN and set the client configuration to TCP/IP the connection worked every
time.
    As far as closing the recordset and the connection, I do as a matter of
good structure.


Quote:
> I'm using Visual Basic 6.0 and SQL 7.0.  In my programs I connect to
> my SQL database two different ways.  When ever I have to display data
> in a datagrid or datalist then I use an ADO data control to establish
> the connection.  If I dont' need to display the data in one of the
> data bound controls then I use the following code to establish my
> connection:

> Private Sub Command1_Click()

> Dim varADO As New ADODB.Connection
> Dim adoRecordset As New ADODB.Recordset

> varADO.Open ("Provider=SQLOLEDB.1;Persist Security Info=False;User
> ID=sa;Initial Catalog=GB_Database;Data Source=gbs01")

> adoRecordset.Open "select * from stored_work_orders where workorder =
> " & Chr(39) & txtWorkOrder.Text & Chr(39), varADO, adOpenStatic,
> adLockOptimistic

> Text1.Text = adoRecordset.Fields(0)

> Set adoRecordset = Nothing
> Set varADO = Nothing

> Exit Sub

> I use this code to make a connection several times in each program.
> About 10 percent of the time when the program tries to open the
> database it freezes for about 10 seconds and then a message pops up
> saying "Timeout Expired".  As soon as I say OK to the message and try
> again it seems to work.  I could bypass that error, but I still have
> the problem of the delay.

> As you can see in my code I don't close the recordset or the
> connection before I set it to nothing.  Do I need to close it first,
> and then set it to nothing, or does it automatically close when I set
> it to nothing?

> Should I establish a connection to the database when the program opens
> and then leave that connection open until the program closes?

> Should I establish my connection using the DSN on each local machine?

> I know SQL is a powerful database program and should have no problem
> supporting my appliations, but this timeout error is killing me.  Any
> help you can give would be greatly appreciated!!!!!!



Sun, 28 Dec 2003 12:00:06 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Timeout Expired Error!!!

2. Timeout Expired Error!!!

3. Timeout expired error

4. Timeout Expired Error With SQL server ODBC

5. Timeout Expired Error With SQL server ODBC

6. VB5, RDO & SQL Server Timeout Expired Error

7. Timeout Expired Error

8. Timeout Expired Error?

9. Timeout Expired Error!!!

10. Error # 5 Timeout expired

11. Error 3234: ODBC--remote query timeout expired

12. run time error: timeout expired

 

 
Powered by phpBB® Forum Software