Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / February 2006

Tip: Looking for answers? Try searching our database.

connection string sql server 2000

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rkush@ktri.com - 05 Feb 2006 23:19 GMT
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 - 06 Feb 2006 00:23 GMT
>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.

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:
http://www.carlprothman.net/Default.aspx?tabid=87#OLEDBProviderForSQLServer

Private Sub cmdTest_Click()

   On Error GoTo Err_Handler

   Dim cnn As ADODB.Connection
   Dim strConn As String

   strConn = "Provider=sqloledb;" & _
             "Data Source=MyServer;" & _
             "Initial Catalog=MyDatabase;" & _
             "Integrated Security=SSPI"

   Set cnn = New ADODB.Connection

   cnn.Open strConn

   MsgBox cnn.ConnectionString, 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
Tom van Stiphout - 06 Feb 2006 03:03 GMT
Check out www.connectionstrings.com
-Tom.

>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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.