Private Sub cmdNext_Click()
Dim itmcpy As Items
Dim MsgBoxStr As Variant
Dim Ubnd As Long, Lbnd As Long
For Each itmcpy In Ini.Section("ODBC").Items
MsgBoxStr = SplitAndDecode(itmcpy.Name)
Ubnd = UBound(MsgBoxStr)
Lbnd = LBound(MsgBoxStr)
Select Case MsgBoxStr(Lbnd)
Case "AddDSN"
If Ubnd < 6 Then
MsgBox "Too Few Parameters"
Else
MsgBox "Add System DSN" & vbCrLf & MsgBoxStr(Lbnd + 1) & vbCrLf & MsgBoxStr(Lbnd + 2) _
& vbCrLf & MsgBoxStr(Lbnd + 2) & vbCrLf & MsgBoxStr(Lbnd + 1) & vbCrLf & MsgBoxStr(Lbnd + 3) & _
vbCrLf & MsgBoxStr(Lbnd + 4)
'Parameter setup
Dim DSN As String
Dim Server As String
Dim Address As String
Dim Database As String
Dim Description As String
Dim Security As String
DSN = "DSN=" & Trim(MsgBoxStr(Lbnd + 1))
Server = "SERVER=" & Trim(MsgBoxStr(Lbnd + 2))
Address = "ADDRESS=" & Trim(MsgBoxStr(Lbnd + 2))
Database = "DATABASE=" & Trim(MsgBoxStr(Lbnd + 1))
Description = "DESCRIPTION=" & Trim(MsgBoxStr(Lbnd + 3))
Security = "NETWORK=dbmssocn"
Select Case MsgBoxStr(Lbnd + 4)
Case "SQL"
SqlDriver = "SQL Server"
SQLParameter = DSN & vbNullChar & Server & vbNullChar & Address & vbNullChar & Security & vbNullChar & _
Database & vbNullChar & Description & vbNullChar & vbNullChar
Case "MSOracle"
SqlDriver = "Microsoft ODBC for Oracle"
SQLParameter = DSN & vbNullChar & Server & vbNullChar & Description & vbNullChar & _
vbNullChar
Case "Oracle73"
SqlDriver = "Oracle73"
SQLParameter = DSN & vbNullChar & Server & vbNullChar & Database & vbNullChar & _
Description & vbNullChar & vbNullChar
End Select
'DSN execution
If SQLConfigDataSource(Me.hwnd, ODBC_ADD_SYS_DSN, SqlDriver, SQLParameter) = False Then
MsgBox "Unable to create the system DSN" & vbCrLf & "-------------------------------" _
& vbCrLf & DSN & vbCrLf & Server & vbCrLf & Address & vbCrLf & Database, _
vbCritical And vbOKOnly, "Error"
End If
End If
Case "DelDSN"
If Ubnd < 2 Then
MsgBox "too Few Parameters"
Else
MsgBox "Delete System DSN" & vbCrLf & MsgBoxStr(Lbnd + 1) & vbCrLf & MsgBoxStr(Lbnd + 2)
Select Case MsgBoxStr(Lbnd + 1)
Case "Access"
SqlDriver = AccessDriver
Case "SQL"
SqlDriver = "SQL Server"
Case "MSOracle"
SqlDriver = "Microsoft ODBC for Oracle"
Case "Oracle73"
SqlDriver = "Oracle73"
End Select
If SQLConfigDataSource(Me.hwnd, ODBC_REMOVE_SYS_DSN, SqlDriver, "DSN=" & MsgBoxStr(Lbnd + 2) & vbNullChar) = False Then
MsgBox "Unable to remove the system DSN", vbCritical And vbOKOnly, "Error"
End If
End If
End Select
Next
ODBCRan = True
NextForm
End Sub
Private Sub Form_Load()
FadeForm Me, 2
ThreeDForm Me
If ScriptExist = False Then
txtServer.Text = "(local)"
txtDescription.Text = "Web connection to ALMIS Database"
optSQLServer.Value = True
Frame1.Visible = True
Else
Frame1.Visible = False
lblUpgrade.Visible = True
End If
End Sub
Private Function CreateMainODBC()
' save all the information
Dim bSuccess As Boolean
Dim hwnd As Long
Dim DSN As String
Dim Server As String
Dim Address As String
Dim Database As String
Dim Description As String
Dim Security As String
DSN = "DSN=" & Trim(txtDatabase.Text)
Server = "SERVER=" & Trim(txtServer.Text)
Address = "ADDRESS=" & Trim(txtServer.Text)
Database = "DATABASE=" & Trim(txtDatabase.Text)
Description = "DESCRIPTION=" & Trim(txtDescription.Text)
Security = "NETWORK=dbmssocn"
If optSQLServer.Value = True Then
SqlDriver = "SQL Server"
SQLParameter = DSN & vbNullChar & Server & vbNullChar & Address & vbNullChar & Security & vbNullChar & _
Database & vbNullChar & Description & vbNullChar & vbNullChar
ElseIf optMSOracle.Value = True Then
SqlDriver = "Microsoft ODBC for Oracle"
SQLParameter = DSN & vbNullChar & Server & vbNullChar & Description & vbNullChar & _
vbNullChar
Else
SqlDriver = "Oracle73"
SQLParameter = DSN & vbNullChar & Server & vbNullChar & Database & vbNullChar & _
Description & vbNullChar & vbNullChar
End If
' bSuccess = SQLConfigDataSource(Me.hwnd, ODBC_ADD_SYS_DSN, Driver, _
' DSN & vbNullChar & Server & vbNullChar & Database & vbNullChar & _
' Description & vbNullChar & vbNullChar)
bSuccess = SQLConfigDataSource(Me.hwnd, ODBC_ADD_SYS_DSN, SqlDriver, SQLParameter)
CreateMainODBC = bSuccess
End Function
Private Function CreateAccessODBC()
Dim bSuccess As Boolean
Dim Driver As String
Dim DSN As String
Dim Server As String
Dim Database As String
Dim Description As String
DSN = "DSN=" & DescriptionDSN
' Server = "SERVER=" & Trim(txtServer.Text)
'Database = "DATABASE=" & gsWebServerPath & WEBSARAS_PATH & "\database\descriptions.mdb"
Database = "DBQ=" & WebServer & SarasRoot & DescDatabase
Description = "DESCRIPTION=" & "Descriptoin stuff"
AccessParameter = DSN & vbNullChar & Database & vbNullChar & _
Description & vbNullChar & vbNullChar
bSuccess = SQLConfigDataSource(0&, ODBC_ADD_SYS_DSN, AccessDriver, AccessParameter)
CreateAccessODBC = bSuccess
End Function