ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Populating data from an external database (https://www.excelbanter.com/excel-programming/307269-populating-data-external-database.html)

DavidC[_2_]

Populating data from an external database
 
This is a second attempt to find an answer. Thanks to the
person who provided an answer the first time but that did
not solve the problem.
I have a workbook with a routine that runs a stored
procedure, sql query on a database over a network. The
routine works well for getting data for all sheets except
one sheet where the number of records being collected
through the stored procedure are larger than any of the
other conditions. The condition used to select the data
for a specific sheet is the value located in cell A1 on
each sheet.
The routine to get the data is:

Set cn = New ADODB.Connection

cn.Open "Provider=SQLOLEDB;Server=XXXXX;Database=YYYY;uid= h
hh;password=0000 "

Set cmd = New ADODB.Command
cmd.ActiveConnection = cn
cmd.CommandText = "ABC SAMPLE"
cmd.CommandType = adCmdStoredProc
cmd.Parameters.Refresh
cmd.Parameters(1).Value = ActiveSheet.Cells(1,1)

Set rst = cmd.Execute()

The code fails during the execution of the final command
Set rst =cnd.Execute()

It seems that it is somehow timing out and failing, and we
have tried adding in application.odbctimeout=90, but it
does not seem to help it could be that the timeout command
is not in the right place.

Does anyone have any thoughts please.

Help will be much appreciated.

Regards

DavidC

DavidC[_2_]

Populating data from an external database
 
Please ignore this posting as I have reposted with newer
information
-----Original Message-----
This is a second attempt to find an answer. Thanks to

the
person who provided an answer the first time but that did
not solve the problem.
I have a workbook with a routine that runs a stored
procedure, sql query on a database over a network. The
routine works well for getting data for all sheets except
one sheet where the number of records being collected
through the stored procedure are larger than any of the
other conditions. The condition used to select the data
for a specific sheet is the value located in cell A1 on
each sheet.
The routine to get the data is:

Set cn = New ADODB.Connection

cn.Open "Provider=SQLOLEDB;Server=XXXXX;Database=YYYY; uid=

h
hh;password=0000 "

Set cmd = New ADODB.Command
cmd.ActiveConnection = cn
cmd.CommandText = "ABC SAMPLE"
cmd.CommandType = adCmdStoredProc
cmd.Parameters.Refresh
cmd.Parameters(1).Value = ActiveSheet.Cells(1,1)

Set rst = cmd.Execute()

The code fails during the execution of the final command
Set rst =cnd.Execute()

It seems that it is somehow timing out and failing, and

we
have tried adding in application.odbctimeout=90, but it
does not seem to help it could be that the timeout

command
is not in the right place.

Does anyone have any thoughts please.

Help will be much appreciated.

Regards

DavidC
.



All times are GMT +1. The time now is 06:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com