Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Populating data from an external database

I have a spreadsheet with a routine that runs a stored
procedure, sql query on a database over a network. The
routine works well for all except one condition where the
number of records are larger than any of the other
conditions. The condition used 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.

Does anyone have any thoughts please.

Help will be much appreciated.

Regards

DavidC
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default Populating data from an external database

Do you need to enclose your command text in square brackets?

cmd.Command.Text="[ABC SAMPLE]"

"DavidC" wrote:

I have a spreadsheet with a routine that runs a stored
procedure, sql query on a database over a network. The
routine works well for all except one condition where the
number of records are larger than any of the other
conditions. The condition used 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.

Does anyone have any thoughts please.

Help will be much appreciated.

Regards

DavidC

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing data via an external database query rtiguy Excel Discussion (Misc queries) 3 October 13th 08 09:02 PM
Tool bar: Data/Import external data/New database query Daniel Setting up and Configuration of Excel 3 February 28th 08 09:40 AM
Import External Data: Saving changes to the database Jean Excel Discussion (Misc queries) 1 April 9th 07 12:12 AM
when importing data from external database does not load into wor. Hari[_2_] Excel Discussion (Misc queries) 0 March 19th 07 04:52 PM
Extractind data from external database TOMMO Excel Programming 1 January 16th 04 02:55 PM


All times are GMT +1. The time now is 07:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"