Home |
Search |
Today's Posts |
#1
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Mail Merge Word 2003 Issue | Mailmerge | |||
mail merge with attachments | Mailmerge | |||
Mail Merge Issue With Office 97 - Excel Data Source | Mailmerge | |||
Word-Excel 2003 - Mail Merge Recipients problem | Mailmerge | |||
Using Hyperlinks in Mail Merge IF...THEN...ELSE Statements | Mailmerge |