connection string sql server 2000

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rkush@ktri.com

    #1

    connection string sql server 2000

    I need the conncetion string to place inside of vba code to connect to
    a sql server. This is require so that I can add data to a table or
    delete data from a table dependenting on the vba 'if-else' condition.

  • Anthony England

    #2
    Re: connection string sql server 2000

    <rkush@ktri.com > wrote in message
    news:1139181542 .134678.83390@g 43g2000cwa.goog legroups.com...[color=blue]
    >I need the conncetion string to place inside of vba code to connect to
    > a sql server. This is require so that I can add data to a table or
    > delete data from a table dependenting on the vba 'if-else' condition.[/color]


    This is a fairly basic question and there must be a million examples posted.
    Here is an example which creates a connection where the SQL Server has been
    configured to accept connections using Windows Integrated security. If this
    is not the case, look at the following for variations:




    Private Sub cmdTest_Click()

    On Error GoTo Err_Handler

    Dim cnn As ADODB.Connectio n
    Dim strConn As String

    strConn = "Provider=sqlol edb;" & _
    "Data Source=MyServer ;" & _
    "Initial Catalog=MyDatab ase;" & _
    "Integrated Security=SSPI"

    Set cnn = New ADODB.Connectio n

    cnn.Open strConn

    MsgBox cnn.ConnectionS tring, vbInformation

    Exit_Handler:

    If Not cnn Is Nothing Then
    If cnn.State <> adStateClosed Then
    cnn.Close
    End If
    Set cnn = Nothing
    End If

    Exit Sub

    Err_Handler:
    MsgBox Err.Description , vbExclamation, "Error No: " & Err.Number
    Resume Exit_Handler

    End Sub


    Comment

    • Tom van Stiphout

      #3
      Re: connection string sql server 2000

      On 5 Feb 2006 15:19:02 -0800, rkush@ktri.com wrote:

      Check out www.connectionstrings.com
      -Tom.
      [color=blue]
      >I need the conncetion string to place inside of vba code to connect to
      >a sql server. This is require so that I can add data to a table or
      >delete data from a table dependenting on the vba 'if-else' condition.[/color]

      Comment

      Working...