Results 1 to 2 of 2
  1. #1

    connect to SQL Server using ADO (WORD2000/VBA)

    What code would I use to connect to a SQL server/Database/Table?
    I have been able to connect using a stored query routine saved through MSQuery, but I want to connect directly to the table, and to pick up the contents od a field and put it in a combobox within a word form.

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Hollywood (sorta), California, USA
    Thanked 0 Times in 0 Posts

    Re: connect to SQL Server using ADO (WORD2000/VBA)

    This code will open a SQL data base using ADO

    Dim cn As New ADODB.Connection
    Dim rs As New ADODB.Recordset

    Sub OpenCMSDataBase()
    On Error GoTo ErrorLabel
    'Timeout is 15 seconds
    cn.ConnectionTimeout = 15
    cn.Open "Provider=MSDASQL;Driver={SQL Server};Server=ServerName;Uid=sa;Pwd=;Database=DAT ABASEName"

    end sub

    Do some research on ADO starting with <A target="_blank" HREF=>this site</A>. MS is moving things around, so this is not the best place to learn ADO, but you'll see some samples in there.
    Kevin <IMG SRC= alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts