Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Poppa Bear Poppa Bear is offline
external usenet poster
 
Posts: 4
Default OpenDataSource SQL Server xpress problem

using :
VS 2005 SE 2 ............ NOT VSTO
Word 2003
Office Interop v 10
Word Interop v 10


Trying to Mailmerge Word 2003 Document with Database.
1. With ACCESS.mdb works fine (lines (A) and (B) below active (C) and (D)
commented out

2. With SQL Server get message about failed to connect. (C) and (D) active
(A) and (B) commented out.

Using same Template file (CVSTemplate3.dot). Access and SQL server Xpress
DBs have same tables and data

Also get a dialog box about "Header Record Delimiters" telling me Data
fields and Data Records must be separated by delimiters. Haven't the faintest
idea what this refers to (sorry) . Can someone help please ? The connection
string for the SQL Server version is the same as I use in the main program
code to open the SQLServer Database - which works fine there, using Windows
Authentification. Have trawled the MS website and others for info with no
success. You are my last hope ! Help --- Please !!

Code snippets :

Private Sub btnOpenWord_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOpenWord.Click
Dim wrdApp As Word.Application =
CType(CreateObject("Word.Application"), Word.Application)
Dim wrdDoc As Word.Document =
CType(wrdApp.Documents.Add("CVSTemplate3.dot", False,
Word.WdDocumentType.wdTypeDocument, True), Word.Document)

Dim sqlQuery As String = "SELECT * FROM [tblEmployees] WHERE
EmployeeLastName LIKE '" & "Jones" & "';"

'' For ACCESS version
'Dim sDBPath As String = "C:\WORK\DBTestEmp.mdb"
'*********************** (A)
'Dim strConnect = System.Type.Missing
'*********************** (B)

'' FOR SQL SERVER Express version
Dim sDBPath As String = "C:\WORK\dbSQLEmpTest.mdf" '
**********************(C)
Dim strConnect As String = "Data
Source=c7e6i3;Database=dbSQLEmpTest;Integrated Security=True;" '
*********************(D)

Try
With wrdDoc.MailMerge
.MainDocumentType = Word.WdMailMergeMainDocType.wdFormLetters
.OpenDataSource(Name:=sDBPath, Connection:=strConnect,
SQLStatement:=sqlQuery)
.Destination = Word.WdMailMergeDestination.wdSendToNewDocument
.Execute(Pause:=False)
End With
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
wrdApp.Visible = True
End Sub
--
Poppa
 
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
Joyfax Server - Client/server-based fax software allows you to sendand receive fax anywhere [email protected] Mailmerge 0 July 15th 08 04:35 AM
Word 2003 MailMerge with SQL Server 2000 problem crm Mailmerge 3 October 9th 06 05:32 PM
MailMerge OpenDataSource SSPI direct SQL Server connection Thomas Mailmerge 3 July 10th 06 02:30 PM
OpenDataSource problem Phill Mailmerge 1 January 29th 05 08:58 AM
Importing Quark Xpress files into Word? EKD Microsoft Word Help 1 January 25th 05 06:51 PM


All times are GMT +1. The time now is 08:32 AM.

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"