Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / March 2005

Tip: Looking for answers? Try searching our database.

Word2003 Mail Merge with SQLServer2000

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kingsley - 01 Mar 2005 15:53 GMT
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;Integrated
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...
Peter Jamieson - 01 Mar 2005 19:25 GMT
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.ContactName from
Customers C where C.CustomerID='ALFI'"

Peter Jamieson

> I'm having problems opening a datasource from SQLServer 2000 to be used
> for a
[quoted text clipped - 17 lines]
>
> Please help...

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.