Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Mail Merge using SQL Server in FoxPro
Message
From
26/08/2003 08:47:04
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
25/08/2003 16:14:39
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00823188
Message ID:
00823361
Views:
15
>Hi:
>
>I am working in a project where I have to use a Mailmerge service based in SQL Server from VFP. I use the following connection but it doesn't work.
>
>owordcontract.ActiveDocument.MailMerge.OpenDataSource(,,,.T.,,,,,,,,"DRIVER={SQL SERVER};DATABASE=MBC;SERVER=MBCDEVTEST;UID=;PWD=","EXECUTE MBC_SP_LEGAL CT,'ALL','6'","")
>
>As you can see I am using a store Procedures instead a single query. I know the connection is good because I receive just the error message "Command Failed!" (That happen after connection)
>
>Can anyone see what is wrong with this picture?
>
>Thanks
>
>Efrain

Efrain,
Seemingly nothing wrong and I don't know why word fails on it. I can suggest a workaround though. Create an MSQuery in word and save it as a .dqy file. You might later check and edit that file manually or even create on the fly seeing the syntax. Then change your merge code to something like :
lcQueryFile = 'c:\myPath\My Query from SQLServer.dqy'

oWordDocument=Createobject("word.application")	&& Create word object
oWordDocument.visible = .t.

With oWordDocument
  .Documents.Add
  .ActiveDocument.MailMerge.OpenDataSource(lcQueryFile)
PS: In MSQuery select no table or temporarily select anyone then delete, view the SQL and write "EXECUTE MBC_SP_LEGAL CT,'ALL','6'" there. Once you get the syntax in .dqy you might create new .dqy on the fly with your new parameters.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform