Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Newbie at mixing ADO and Excel

I'm not a newbie to VB or ADO or Excel, but just to mixing them all. I'm
trying to get the output of an SQL Stored procedure to be the data for a
spreadsheet--the ultimate goal of which is so that I can put a button on a
spreadsheet for a user and tell them that they can update/run it for any set
of parameters that they desire. I can do the prompts and get the data thru
ADO into a recordset, but then how do I assign it to a range of cells?

TIA!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Newbie at mixing ADO and Excel

Bryan,

If you have Excel 2000 or later, you can use the CopyFromRecordset method to
drop the rs into a worksheet range

Worksheets("Sheet1").Range("A2").CopyFromRecordset oRS

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Bryan Dickerson" wrote in message
...
I'm not a newbie to VB or ADO or Excel, but just to mixing them all. I'm
trying to get the output of an SQL Stored procedure to be the data for a
spreadsheet--the ultimate goal of which is so that I can put a button on a
spreadsheet for a user and tell them that they can update/run it for any

set
of parameters that they desire. I can do the prompts and get the data

thru
ADO into a recordset, but then how do I assign it to a range of cells?

TIA!




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Newbie at mixing ADO and Excel

Thanks!

Now, I have to confess that I *thought* I could do the ADO part, but I've
previously only worked with straight query text that is passed to the
server. This time I'm having to call a stored procedure as I indicated
below and I'm not having much luck. The SP has 3 parameters. Can you help
or do I need to take this to another NG?

This is what I currently have:
------------------------------
oCmd.CommandType = adCmdText
oCmd.CommandText = "EXEC SP_Report '" & _
CustomerNumber & "', '" &
_
StartDate & "', '" &
EndDate & "'"
Set oRSet = oCmd.Execute
------------------------------
.... it's not working. Any ideas?
TIA!

"Bob Phillips" wrote in message
...
Bryan,

If you have Excel 2000 or later, you can use the CopyFromRecordset method

to
drop the rs into a worksheet range

Worksheets("Sheet1").Range("A2").CopyFromRecordset oRS

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Bryan Dickerson" wrote in message
...
I'm not a newbie to VB or ADO or Excel, but just to mixing them all.

I'm
trying to get the output of an SQL Stored procedure to be the data for a
spreadsheet--the ultimate goal of which is so that I can put a button on

a
spreadsheet for a user and tell them that they can update/run it for any

set
of parameters that they desire. I can do the prompts and get the data

thru
ADO into a recordset, but then how do I assign it to a range of cells?

TIA!






  #4   Report Post  
Posted to microsoft.public.excel.programming
TK TK is offline
external usenet poster
 
Posts: 177
Default Newbie at mixing ADO and Excel

Hi Bryan

search this string
How To Pull Access Query
in the "Search For" box on this page
date 12/7/2004
There were some suggestions close to your topic.
Post back if you need more information but you will need to
be a little more specific as to how far you are with your code.
Have you made a connection to the DB, have you made a
reference to the ADO active X library???

Good Luck
TK




"Bryan Dickerson" wrote:

Thanks!

Now, I have to confess that I *thought* I could do the ADO part, but I've
previously only worked with straight query text that is passed to the
server. This time I'm having to call a stored procedure as I indicated
below and I'm not having much luck. The SP has 3 parameters. Can you help
or do I need to take this to another NG?

This is what I currently have:
------------------------------
oCmd.CommandType = adCmdText
oCmd.CommandText = "EXEC SP_Report '" & _
CustomerNumber & "', '" &
_
StartDate & "', '" &
EndDate & "'"
Set oRSet = oCmd.Execute
------------------------------
.... it's not working. Any ideas?
TIA!

"Bob Phillips" wrote in message
...
Bryan,

If you have Excel 2000 or later, you can use the CopyFromRecordset method

to
drop the rs into a worksheet range

Worksheets("Sheet1").Range("A2").CopyFromRecordset oRS

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Bryan Dickerson" wrote in message
...
I'm not a newbie to VB or ADO or Excel, but just to mixing them all.

I'm
trying to get the output of an SQL Stored procedure to be the data for a
spreadsheet--the ultimate goal of which is so that I can put a button on

a
spreadsheet for a user and tell them that they can update/run it for any

set
of parameters that they desire. I can do the prompts and get the data

thru
ADO into a recordset, but then how do I assign it to a range of cells?

TIA!







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Newbie at mixing ADO and Excel

Bryan,

What does it do instead of work?

Tim.


"Bryan Dickerson" wrote in message
...
Thanks!

Now, I have to confess that I *thought* I could do the ADO part, but I've
previously only worked with straight query text that is passed to the
server. This time I'm having to call a stored procedure as I indicated
below and I'm not having much luck. The SP has 3 parameters. Can you

help
or do I need to take this to another NG?

This is what I currently have:
------------------------------
oCmd.CommandType = adCmdText
oCmd.CommandText = "EXEC SP_Report '" & _
CustomerNumber & "', '"

&
_
StartDate & "', '" &
EndDate & "'"
Set oRSet = oCmd.Execute
------------------------------
... it's not working. Any ideas?
TIA!





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Newbie at mixing ADO and Excel

This is my code (pared down to the important parts, of course):
--------------------------------------------------------------------------
Dim oCon As New ADODB.Connection
Dim oCmd As New ADODB.Command
Dim oRSet As ADODB.Recordset

ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist
Security Info=True;Initial Catalog=Mirror;Data Source=SQLServer;Use
Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Use Encryption
for Data=False;Tag with column collation when possible=False"

<snip Prompt for 3 parameters and verify </snip

oCon.Open ConnectionString
oCmd.CommandType = adCmdText
oCmd.CommandText = "EXEC SPReport '" & CustomerNumber & "', '" & _
StartDate & "', '" & EndDate & "'"
Set oRSet = oCmd.Execute
Worksheets("1032").Range("A1").CopyFromRecordset oRSet
--------------------------------------------------------------------------

Instead of work, it returns column headers, but no data in any columns.
Hmmm...


"Tim Williams" <saxifrax at pacbell dot net wrote in message
...
Bryan,

What does it do instead of work?

Tim.


"Bryan Dickerson" wrote in message
...
Thanks!

Now, I have to confess that I *thought* I could do the ADO part, but

I've
previously only worked with straight query text that is passed to the
server. This time I'm having to call a stored procedure as I indicated
below and I'm not having much luck. The SP has 3 parameters. Can you

help
or do I need to take this to another NG?

This is what I currently have:
------------------------------
oCmd.CommandType = adCmdText
oCmd.CommandText = "EXEC SP_Report '" & _
CustomerNumber & "',

'"
&
_
StartDate & "', '" &
EndDate & "'"
Set oRSet = oCmd.Execute
------------------------------
... it's not working. Any ideas?
TIA!





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Newbie at mixing ADO and Excel

Are you fomatting the StartDate and EndDate strings correctly?
Jamie.

--

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
Mixing Landscape and Portrait pages in one Excel 2007 Worksheet. TonyR[_2_] Excel Discussion (Misc queries) 5 April 3rd 23 06:43 PM
mixing zip with zip+4 and then sorting JWCrosby Excel Discussion (Misc queries) 2 September 25th 08 08:48 PM
mixing up a list dkb43 Excel Discussion (Misc queries) 1 August 6th 08 08:20 PM
Mixing up golfing groups (excel format) GeorgiaEddie Excel Discussion (Misc queries) 2 January 21st 07 10:56 PM
Mixing up the arguments michaelr586 Excel Worksheet Functions 2 September 24th 05 09:54 AM


All times are GMT +1. The time now is 05:44 PM.

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"