dingleberry
Programmer
So, I would like to distribute a spreadsheet to several users. The spreadsheet (xlsm) has a button which when clicked calls a subroutine to write to a MySQL database that is shared on our local network. All users have access to the MySQL IP Address but not all users have the ODBC driver installed. In fact, many do not. I like the idea of being able to send out a spreadsheet (because most users are familiar with this and it is much easier than writing a web based front end using php) to get information from users but I don't know how to get around this ODBC driver issue. Can anyone provide some direction or help on this? I have attached the VBA code below
Code:
Dim oConn As ADODB.Connection
Private Sub ConnectDB()
Set oConn = New ADODB.Connection
oConn.Open "DRIVER={MySQL ODBC 5.2 Unicode Driver};SERVER=10.144.205.198;DATABASE=store_survey;USER=****;PASSWORD=********;Option=3"
End Sub
Function esc(txt As String)
esc = Trim(Replace(txt, "'", "\'"))
End Function
'Dim rs As ADODB.Recordset
Private Sub InsertData()
Set rs = New ADODB.Recordset
ConnectDB
With wsBooks
For rowCursor = 2 To 11
strSQL = "INSERT INTO `store_survey`.`tutorial` (`title`, `author`, `price`) VALUES ('" & esc(.Cells(rowCursor, 1)) & "', '" & esc(.Cells(rowCursor, 2)) & "', '" & esc(.Cells(rowCursor, 3)) & "');"
'MsgBox strSQL
rs.Open strSQL, oConn, adOpenDynamic, adLockOptimistic
Next
End With
End Sub
Sub Button3_Click()
Call InsertData
End Sub