You don't need to change anything -- assuming you were using MySQL rather than the Ms SQL server
For example (type either mariadb or mysql on the command line).
Identical on Windows too !!!
I'd give it a shot. Try it on a Windows VM first if you are a bit dubious.
View attachment 90060
cheers
jimbo
HaHa, dont have to change anything? Here is a snippet of my code to begin connection to a database server
Private Sub Form_Load()
'formloads even when not called
cmdCreate.Enabled = False
cmdTest.Enabled = False
cmdFix.Enabled = False
cmdOK.Enabled = False
Set clsElastic = New clsElasticForms
clsElastic.Form = Me
'get the system settings
currHRes = GetDeviceCaps(hdc, HORZRES)
currVRes = GetDeviceCaps(hdc, VERTRES)
If currHRes < 800 Then
clsElastic.MinHeight = 4000
clsElastic.MinWidth = 6000
Me.Height = 4000
Me.Width = 6000
End If
If currHRes >= 800 And currHRes < 1024 Then
clsElastic.MinHeight = 4000
clsElastic.MinWidth = 6000
Me.Height = 4400
Me.Width = 6200
End If
If currHRes >= 1024 Then
clsElastic.MinHeight = 4000
clsElastic.MinWidth = 6000
Me.Height = 5000
Me.Width = 7000
End If
'save old good connection string
If frmLogon.Connectstring <> "" Then PreviousConn2 = frmLogon.Connectstring
If frmLogon.Connectstring <> "" Then PreviousConn = frmLogon.Connectstring
'no current connection then assign it
If frmLogon.Connectstring = "MySQL" Then
frmLogon.cnConnector.ConnectionString = "" & _
"Provider=MSDASQL.1;" & _
"DRIVER={MySQL ODBC 3.51 Driver};" & _
"DESC=;" & _
"DATABASE=;" & _
"SERVER=localhost;" & _
"UID=;" & _
"PASSWORD=;" & _
"PORT=;" & _
"OPTION=35;" & _
"STMT=;"
PreviousConn = frmLogon.cnConnector.ConnectionString
frmLogon.Connectstring = frmLogon.cnConnector.ConnectionString
End If
'test for MySql, if not present then load default
WhichOne = InStr(1, frmLogon.Connectstring, "MySQL")
If WhichOne = 0 Then
If frmLogon.dbasetype = "SQLServer" Or frmLogon.dbasetype = "" Then
'Now you know that this is a SQLServer string so reset it for MySQL use
PreviousConn = "" & _
"Provider=MSDASQL.1;" & _
"DRIVER={MySQL ODBC 3.51 Driver};" & _
"DESC=;" & _
"DATABASE=;" & _
"SERVER=localhost;" & _
"UID=;" & _
"PASSWORD=;" & _
"PORT=;" & _
"OPTION=35;" & _
"STMT=;"
End If
End If
On Error GoTo errhandler
'find the current provider
A1 = InStr(1, PreviousConn, "Provider=", vbTextCompare)
If A1 <> 0 Then
A2 = InStr(A1, PreviousConn, ";")
If A2 = 0 Then A2 = Len(PreviousConn)
Text1(0).Text = Mid(PreviousConn, A1 + 9, A2 - A1 - 9)
End If
'find the current driver
A1 = InStr(1, PreviousConn, "DRIVER=", vbTextCompare)
If A1 <> 0 Then
A2 = InStr(A1, PreviousConn, ";")
If A2 = 0 Then A2 = Len(PreviousConn)
Text1(1).Text = Mid(PreviousConn, A1 + 7, A2 - A1 - 7)
End If
'find the current server
A1 = InStr(1, PreviousConn, "SERVER=", vbTextCompare)
If A1 <> 0 Then
A2 = InStr(A1, PreviousConn, ";")
If A2 = 0 Then A2 = Len(PreviousConn)
Text1(2).Text = Mid(PreviousConn, A1 + 7, A2 - A1 - 7)
End If
'find the current database name
' A1 = InStr(1, PreviousConn, "DATABASE=", vbTextCompare)
' A2 = InStr(A1, PreviousConn, ";")
' Combo1.AddItem Mid(PreviousConn, A1 + 9, A2 - A1 - 9)
'find the current user
A1 = InStr(1, PreviousConn, "UID=", vbTextCompare)
If A1 <> 0 Then
A2 = InStr(A1, PreviousConn, ";")
If A2 = 0 Then A2 = Len(PreviousConn)
Text1(4).Text = Mid(PreviousConn, A1 + 4, A2 - A1 - 4)
End If
'find the current password
A1 = InStr(1, PreviousConn, "PASSWORD=", vbTextCompare)
If A1 <> 0 Then
A2 = InStr(A1, PreviousConn, ";")
If A2 = 0 Then A2 = Len(PreviousConn)
Text1(5).Text = Mid(PreviousConn, A1 + 9, A2 - A1 - 9)
End If
'find the current password if password is empty, like not used, so look for pwd
If Text1(5).Text = "" Then
A1 = InStr(1, PreviousConn, "PWD=", vbTextCompare)
If A1 <> 0 Then
A2 = InStr(A1, PreviousConn, ";")
If A2 = 0 Then A2 = Len(PreviousConn)
Text1(5).Text = Mid(PreviousConn, A1 + 4, A2 - A1 - 4)
End If
End If
If A1 = 0 Then Text1(5).Text = ""
'find the current port
A1 = InStr(1, PreviousConn, "PORT=", vbTextCompare)
If A1 <> 0 Then
A2 = InStr(A1, PreviousConn, ";")
If A2 = 0 Then A2 = Len(PreviousConn)
Text1(6).Text = Mid(PreviousConn, A1 + 5, A2 - A1 - 5)
End If
'find the current option
A1 = InStr(1, PreviousConn, "OPTION=", vbTextCompare)
If A1 <> 0 Then
A2 = InStr(A1, PreviousConn, ";")
If A2 = 0 Then A2 = Len(PreviousConn)
Text1(7).Text = Mid(PreviousConn, A1 + 7, A2 - A1 - 7)
End If
'Text1(0).Text = 'provider
'Text1(1).Text = 'driver
'Text1(2).Text = 'server
'combo1.text = 'dbname used to be text1(3).text
'Text1(4).Text = 'uid
'Text1(5).Text = "" 'password
'Text1(6).Text = 'port
'Text1(7).Text = 'option
Exit Sub
errhandler:
Text1(0).Text = "MSDASQL.1" 'provider
Text1(1).Text = "{MySQL ODBC 3.51 Driver}" 'driver
Text1(2).Text = "localhost" 'server
'combo1.text = 'dbname used to be text1(3).text
Text1(4).Text = "" 'uid
Text1(5).Text = "" 'password
Text1(6).Text = "3306" 'port
Text1(7).Text = "35" 'option
End Sub