0

I'm running a MySQL server on my old computer and trying to connect it from my current computer. I would like to access to the server from Excel but I keep getting the error:

'[Microsoft] [ODBC Driver Manager] Data source name not found and no default driver specified'

I've downloaded a 'MySQL connector ODBC 8.0.20 win 32' which should match my computer requirements. At this point I'm quite clueless why I keep getting the error. Please find my VBA code below.

Private Sub Data_to_SQL_Click()

Dim con As ADODB.Connection
Set con = New ADODB.Connection

Dim strConn As String

strConn = "Driver={MySQL ODCB 8.0 Unicode Driver};SERVER=(my old computer ip address);DATABASE=Database;USER=root;PASSWORD=(password)"

con.Open strConn

Dim rng As Range
Set rng = Application.Range("A2:E14")
Dim row As Range
For Each row In rng.Rowss
    Dim Sql As String
    Sql = "insert into kavijamaarat (pvm, ravintola, ruoka, hinta, kpl) values ('" & row.Cells(1).Value & "', '" & row.Cells(2).Value & "', '" & row.Cells(3).Value & "', '" & row.Cells(4).Value & "', '" & row.Cells(5).Value & "')"
    con.Execute Sql
Next row

con.Close

MsgBox "Done"

End Sub

2
  • ODBC, not ODCB. Commented May 20, 2020 at 8:07
  • 'For Each row In rng.Rowss' ?? should be rng.rows (single s) Commented May 20, 2020 at 8:51

1 Answer 1

1

Rewrite

strConn = "Driver={MySQL ODCB 8.0 Unicode Driver};SERVER=(my old computer ip address);DATABASE=Database;USER=root;PASSWORD=(password)"

to

strConn = "Driver={MySQL ODBC 8.0 Unicode Driver};SERVER=(my old computer ip address);DATABASE=Database;USER=root;PASSWORD=(password)"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.