[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Client side VBScript passing parameters to a SQL Server DSN

Posted on 2003-11-23
5
Medium Priority
?
1,212 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 400 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses

650 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