datasource not found

jnash

Well-known member
Joined
Oct 20, 2006
Messages
111
Programming Experience
Beginner
I have been trying to get a mail merge working for ages made this up from various sites, im gettin the error after the ODBC connecter page comes up and i click okay

the error is "cannot open datasource" any immediate ideas ? thanks

VB.NET:
Public Sub domailmerge()
        Dim oApp As Word.Application
        Dim oDoc As Word.Document

        'Start a new document in Word.
        oApp = New Word.Application
        'Make Word visible (to see the dialog box).
        oApp.Visible = True

        oDoc = oApp.Documents.Add
        With oDoc.MailMerge
            .MainDocumentType = Word.WdMailMergeMainDocType.wdFormLetters

            'Set up the data source for the mail merge.
            Dim sSQL As String
            Dim sConn As String
            sSQL = "Select FirstName, LastName from tblmember"
            sConn = "C:\Documents and Settings\halo9\Desktop\supervid tblmember.odc"
            .OpenDataSource(Name:=sConn, SQLStatement:=sSQL)

            'Set up the document with the fields.
            .EditMainDocument()
            .Fields.Add(Range:=oApp.Selection.Range, Name:="FirstName")
            oApp.Selection.TypeParagraph()
            .Fields.Add(Range:=oApp.Selection.Range, Name:="LastName")
            oApp.Selection.TypeParagraph()

            'Execute the merge.
            .Destination = Word.WdMailMergeDestination.wdSendToNewDocument
            .Execute()
        End With

        'Clean up.
        oDoc = Nothing
        oApp = Nothing

    End Sub

im using mysql if that helps?
 
Last edited:
datasource file i created in windows ive tried to use mysql connecion but i cant see it fitting in correctly???
 
Back
Top