Solved

Client side VBScript passing parameters to a SQL Server DSN

Posted on 2003-11-23
5
1,204 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

734 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