Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21183

Connect to SQL server database

$
0
0
Hello All, I'm about to convert my connection from MS-Access database to SQL server database which i create but i don't know how to convert my connection code below that i used to connect to MS Access DB. Please can anyone advice me to what part of code should i remove and what should i add to help connect it to SQL server DB. Thank you all inadvance and sorry to bother you all with my issue.
Code:

On Error GoTo OpenLocalDB_Error
     
 
  Screen.MousePointer = vbHourglass
  dbPath = GetSetting(App.Title, "Settings", "Path")
    'loads the database path, if there isnt one it loads D:
 '  If dbPath = "" Then
    SaveSetting App.Title, "Settings", "Path", "D:" ' For multi application and one database add : "\\BRSS-PC\"
    dbPath = GetSetting(App.Title, "Settings", "Path")
  ''  End If
 
 
  Screen.MousePointer = vbHourglass
  RecPath = dbPath & "\Reports\"
    'uses dbPath to build database path
    g_strDBName = dbPath & "\BarqCell Data\DSS.mdb;Jet " & "OLEDB:Database Password=brss"
    'creates a new databse conection and sets the conection string
  Set dbContact = New ADODB.Connection
  Constring = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
  "Data Source=" & g_strDBName
  dbContact.ConnectionString = Constring
  'Opens the database conection
  dbContact.Open

Editing: Try to connect to SQL server 2008.

Viewing all articles
Browse latest Browse all 21183

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>