ADODB - Trying to Open

sdruley

Well-known Member
Joined
Oct 3, 2010
Messages
557
Office Version
  1. 365
Platform
  1. Windows
In the following,there is just one line of code I can't get right. Any ideas on this? I am trying to take a text string and upload it from my computer to an external server.
The error message is [Microsoft][ODBC Drive Manager] Data source name not found and no default driver specified

Code:
            If Range("upload") Then
            aa = Application.Range("GH14").Value
            bb = Format(Range("TOE"), "mm/dd/yyyy")
            cc = Format(Range("TOE"), "h:mm:ss")
            dd = Range("ver").Value
            InsertData aa, bb, cc, dd
            End If

Code:
Sub InsertData(ByVal strFirst As String, ByVal strSecond As String, ByVal strThird As String, ByVal strFourth As String)
    Dim conn As New ADODB.Connection
    Dim sql As String
       
    Set conn = New ADODB.Connection
    
    conn.Open "DFRSRainbow" ' THIS LINE OF CODE IS NOT RIGHT
    
    ' delete table contents
    sql = "DELETE FROM tradingdata;"
    conn.Execute sql
    
    ' write new entries using passed arguments
    sql = "insert into tradingdata (first,second,third,fourth) values ('" & strFirst & "','" & strSecond & "','" & strThird & "','" & strFourth & "');"
    conn.Execute sql
    
    ' clean up
    conn.Close
    Set conn = Nothing
End Sub
 
Last edited:

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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