Stored proceedure with OLEDB ?

M

Michael

Is there any way of persuading an OLEDB connection to accept a stored
proceedure for mail merge?

I'm trying to avoid storing any connection information on client machines
and really want to avoid creating a DSN on each machine.

Michael
 
C

cerullian

Here is some of my code that works with stored procedures:

With ActiveDocument.MailMerge
.MainDocumentType = wdFormLetters

.OpenDataSource Name:=strConnect, _
SQLStatement:=strSQL

.Destination = wdSendToNewDocument
.Execute Pause:=False
End With

(Here strConnect is the path & name of an ODC or UDL file containing
the connection string. ) To answer your question, strSQL would be
something like this:

strSQL = "exec procMyStoredProc"

The exec part is necessary to make it work. You can append parameters
if needed.

Be aware that interoperability between Word and SQL Server just
sucks!! I wonder if anyone in the Word division has ever tried to use
it. One serious limitation is that your stored procedures must start
with the SELECT statement. You can't declare any variables, or do any
pre-processing; even SET NOCOUNT ON will cause it to fail.

cerullian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top