Solved

Client side VBScript passing parameters to a SQL Server DSN

Posted on 2003-11-23
5
1,207 Views
Last Modified: 2010-05-18
I have a web page that fires client side VBScript. This script initiates a mail merge with a local word document on a locally setup DSN.

I can get the following [extract] to work without parameters:
wrdDoc.MailMerge.OpenDataSource "", , , , , , , , , , , "DSN=MyDSN", "sp_MySproc", , , wdMergeSubTypeWord2000
wrdDoc.MailMerge.Destination = wdSendToNewDocument
wrdDoc.MailMerge.Execute False


Is it possible to pass parameters into the sproc that Im executing?

Thanks..
0
Comment
Question by:niico
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
ambientnet earned 100 total points
ID: 9808327
Have you tried:

wrdDoc.MailMerge.OpenDataSource "", , , , , , , , , , , "DSN=MyDSN", "exec sp_MySproc @Param1='lala', @Param2='lalala'", , , wdMergeSubTypeWord2000
wrdDoc.MailMerge.Destination = wdSendToNewDocument
wrdDoc.MailMerge.Execute False

??

You may also not want to name your procedures with sp_ as a prefix... doing so asks SQL to search the masterdb first, and then your DSN's default database second.

-m
0
 

Author Comment

by:niico
ID: 9811549
Great

Thanks twice for the added sp_ advice - didnt realise that!

I'll check it out and get back to you...
0
 

Author Comment

by:niico
ID: 9838709
Is there any way to define the datatype of each parameter? does it matter in any case?
0
 
LVL 1

Expert Comment

by:ambientnet
ID: 9839966
niico,
     That's an interesting question. Does it matter? That depends on what you're trying to pass. If you're trying to pass strings (char's, varchars, nvarchars etc), then I wouldn't worry about it. If you're trying to pass an Int, I wouldn't worry about it. But you can always open a recordset by way of ADODB.Command and assign Parameters and their Types using the cmdVariable.CreateParameter Method.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdamth01_14.asp   has more information.

But that's a different code structure than what you're trying to do, from what I can see. In that instance, you'd open the "DSN"/Recordset and have your MailMerge Code inside of a Loop.

I'm not sure if you need to go further than 'exec'.. I'd try using your current code and seeing if you run into any problems. My thought is that you won't. ;)
Let me know when things work out!

-m

0
 

Author Comment

by:niico
ID: 9957600
This works well - thanks very much!
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question