title: How to read .csv file with VBScript and ADO
body: <p><strong>The Goal</strong></p>
  
  <p>Write a program that reads .csv files and uploads them to a database. It must run on Windows 10 with no special installations necessary.</p>
  
  <p><strong>What I've Tried</strong></p>
  
  <p>I'm familiar with VBScript and ADO connections (I've actually already written and tested the file upload portion of the program). Now all I'm trying to do is read in the .csv file with ADO (see why to use ADO instead of split() here: <a href="https://msdn.microsoft.com/en-us/library/ms974559.aspx" rel="nofollow noreferrer">https://msdn.microsoft.com/en-us/library/ms974559.aspx</a>)</p>
  
  <p>The article above creates the .csv connection using the Microsoft Jet Database Engine, which is not installed by default, so I tried with Microsoft Text Driver, as recommended by other sources.</p>
  
  <p><strong>The Problem</strong></p>
  
  <p>I'm encountering an error upon attempting a connection. The error says:</p>
  
  <pre><code>Microsoft OLE DB Provider for ODBC
  Drivers: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
  </code></pre>
  
  <p>That error occurs whether run from 32-bit or 64-bit cmd (this is where I got the 32-bit process: <a href="https://stackoverflow.com/questions/2806584/how-do-i-run-a-vbscript-in-32-bit-mode-on-a-64-bit-machine">How do I run a VBScript in 32-bit mode on a 64-bit machine?</a>). The Microsoft Text Driver can be found in the 32-bit ODBC Drivers.</p>
  
  <p>I do have a file called test.csv on my desktop and it contains the text <code>"Cell1","Cell2","Cell3"</code></p>
  
  <p><strong>The Code</strong></p>
  
  <pre><code>Const adOpenStatic = 3
  Const adLockOptimistic = 3
  Const adCmdText = &amp;H0001
  
  set WshShell = CreateObject("Wscript.shell")
  strDesktop = WshShell.SpecialFolders("Desktop")
  
  Set fileConn = CreateObject("ADODB.Connection")
  Set fileRS = CreateObject("ADODB.Recordset")
  
  strPathtoTextFile = strDesktop &amp; "\"
  ' Wscript.Echo(strPathtoTextFile)
  fileConn.ConnectionString = "Driver={Microsoft Text Driver (*.txt;*.csv)};DBQ=" &amp; strPathtoTextFile &amp; ";"
  
  fileConn.Open
  
  fileRS.Open "SELECT * FROM test.csv", _
          fileConn, adOpenStatic, adLockOptimistic, adCmdText
  </code></pre>
  
  <p>The error occurs on the line <code>fileConn.Open</code>. The code is a modified snippet from the Microsoft article above.</p>
  
  <p>Any ideas why I'm getting this error?</p>