ADODB MYSQL - Can't create TCP/IP socket (10093)

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
788
Office Version
  1. 365
Platform
  1. Windows
Hi,
First i will link my thread i posted on Reddit related to this which i never managed to resolve:
ADODB MYSQL - Can't create TCP/IP socket (10093)

I have some code which inserts data into a database, when i try use the code to insert into both (an access DB and MySQL DB) i get this error. (Can't create TCP/IP socket (10093)

I have tried using CNN for 1 and CNN2 for the other.
I have tried using Access first, and MYSQL first

Note: if i only use 1 or the other it is fine with no problems
as at first i thought was a firewall issue but using only MYSQL works ok

Example code:
VBA Code:
Sub UploadData()
    ADODBInsertACCESS
    ADODBInsertMYSQL
End Sub


Sub ADODBInsertACCESS()

    Set Cnn = New ADODB.Connection
    Cnn.Open "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=xxx;"
                
    I = 2
    
    VBL2 = Sheet1.Cells(I, 2).Value
    VBL3 = Sheet1.Cells(I, 3).Value
    VBL4 = Sheet1.Cells(I, 4).Value
    VBL5 = Sheet1.Cells(I, 5).Value

    MYSQL = "INSERT INTO TABLE1 (COLUMN2,COLUMN3,COLUMN4,COLUMN5) VALUES ('" & VBL2 & "','" & VBL3 & "','" & VBL4 & "','" & VBL5 & "');"
    Cnn.Execute MYSQL
   
    Cnn.Close
    Set Cnn = Nothing

End Sub

Sub ADODBInsertMYSQL()

    Set Cnn = New ADODB.Connection
    Cnn.Open "Driver={MySQL ODBC 5.1 Driver};SERVER=xxx;DATABASE=xxx;UID=xxx;PWD=xxx;PORT=xxx;"
                
    I = 2
    
    VBL2 = Sheet1.Cells(I, 2).Value
    VBL3 = Sheet1.Cells(I, 3).Value
    VBL4 = Sheet1.Cells(I, 4).Value
    VBL5 = Sheet1.Cells(I, 5).Value

    MYSQL = "INSERT INTO TABLE1 (COLUMN2,COLUMN3,COLUMN4,COLUMN5) VALUES ('" & VBL2 & "','" & VBL3 & "','" & VBL4 & "','" & VBL5 & "');"
    Cnn.Execute MYSQL
   
    Cnn.Close
    Set Cnn = Nothing

End Sub

appreciate any help
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
1 bump at the chance someone has a suggestion

Might just have to settle for using 1 or the other
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top