Reply
 
Thread Tools Display Modes
  #1   Report Post  
Kingsley
 
Posts: n/a
Default Word2003 Mail Merge with SQLServer2000

I'm having problems opening a datasource from SQLServer 2000 to be used for a
mail merge word 2003. Each time I run the code below, I get an error message
saying "datasource can not be opened".

object oFile = System.Environment.CurrentDirectory + "\\Document.doc";
object SubType = WdMergeSubType.wdMergeSubTypeOLEDBWord;
WordDoc = WordApp.Documents.Open(ref oFile,ref Unknown,...,ref Unknown)
object sDBConnection = "server=localhost;database=Northwind;Integrate d
Security=SSPI;";
object query = "Select CompanyName,Address,City,Country,ContactName from
Customers where CustomerID='ALFI'";

WordDoc.MailMerge.OpenDataSource(DSName,ref format,ref Unknown,ref
Unknown,ref TRUE,ref Unknown, ref Unknown,ref Unknown,ref Unknown,ref
Unknown,ref Unknown,ref sDBConnection,ref query,ref Unknown,ref Unknown,ref
SubType);

Please help...


  #2   Report Post  
Peter Jamieson
 
Posts: n/a
Default

What is in DSName? For this to work, it will probably need to be a .udl file
or a .odc file, unless you want to open the connection using ODBC. The .odc
file can be completely empty as long as all the necessary connection
information is passed in the OpenDataSource call's connection parameter. In
this case, it should start with the name of the OLEDB provider, e.g.

Provider=providername (sorry,I do not have the details to hand)

You may alsofindthat using a table alias in the SQLstatement jhelps, e.g.
instead of

"Select CompanyName,Address,City,Country,ContactName from Customers where
CustomerID='ALFI'"

try

"Select C.CompanyName,C.Address,C.City,C.Country,C.Contact Name from
Customers C where C.CustomerID='ALFI'"

Peter Jamieson

"Kingsley" wrote in message
...
I'm having problems opening a datasource from SQLServer 2000 to be used
for a
mail merge word 2003. Each time I run the code below, I get an error
message
saying "datasource can not be opened".

object oFile = System.Environment.CurrentDirectory + "\\Document.doc";
object SubType = WdMergeSubType.wdMergeSubTypeOLEDBWord;
WordDoc = WordApp.Documents.Open(ref oFile,ref Unknown,...,ref Unknown)
object sDBConnection = "server=localhost;database=Northwind;Integrate d
Security=SSPI;";
object query = "Select CompanyName,Address,City,Country,ContactName from
Customers where CustomerID='ALFI'";

WordDoc.MailMerge.OpenDataSource(DSName,ref format,ref Unknown,ref
Unknown,ref TRUE,ref Unknown, ref Unknown,ref Unknown,ref Unknown,ref
Unknown,ref Unknown,ref sDBConnection,ref query,ref Unknown,ref
Unknown,ref
SubType);

Please help...




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail Merge Word 2003 Issue S.Nicks Mailmerge 5 February 20th 09 01:55 AM
mail merge with attachments AS Mailmerge 5 April 9th 05 09:49 AM
Mail Merge Issue With Office 97 - Excel Data Source Matt Thorley Mailmerge 1 February 15th 05 11:38 PM
Word-Excel 2003 - Mail Merge Recipients problem AYager Mailmerge 2 January 11th 05 04:11 AM
Using Hyperlinks in Mail Merge IF...THEN...ELSE Statements Mark V Mailmerge 8 November 30th 04 01:31 PM


All times are GMT +1. The time now is 01:45 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"