Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Option Explicit
Private Const ERROR_SUCCESS = 0&
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal _
lpSubKey As String, phkResult As Long) As Long
Private Function DSNExists(DSN As String) As Boolean
Const ODBCINIPath = "Software\ODBC\ODBC.INI\"
Dim TempPath As String
Dim hCurKey As Long
Dim lRegResult As Long
TempPath = ODBCINIPath & DSN
lRegResult = RegOpenKey(HKEY_LOCAL_MACHINE, TempPath, hCurKey)
If lRegResult = ERROR_SUCCESS Then
'it exists on the system
DSNExists = True
lRegResult = RegCloseKey(hCurKey)
Else
DSNExists = False
End If
End Function
Private Sub Form_Load()
If DSNExists("YOUR_DSN_NAME_HERE") Then
'Code here to connect
Else
'Give user option to create
End If
End Sub
Dim con As ADODB.Connection
Set Con = New ADODB.Connection
con.ConnectionString = "Provider=sqloledb.1;User ID=YOUR_USER;Password=YOUR_PASSWORD;Data Source=SERVER_NAME;Initial Catalog=DATABASE_NAME"
con.Open
....