title: VBScript error connecting to Sybase Database - Provider cannot be found
body: <p>I am writing a VBScript that connects to a Sybase database, reads some data from a table and stores it in variables, then connects to a MS SQL server and inserts data into tables with the variable data that was stored earlier.</p>
  
  <p>I have found a couple of existing scripts to get me going <a href="https://gallery.technet.microsoft.com/scriptcenter/600a75b2-c0a4-4a05-b013-cf7c556a4023" rel="nofollow">here</a> and <a href="http://www.ntechcomm.com/2014/06/how-to-connect-to-access-database-with-vbscript/" rel="nofollow">here</a>.</p>
  
  <p>I understand these just fine. The only problem is the Database connection string itself. Here is the connection string that is currently being used. <em>(I have used correct values in the actual script but changed some here for security purposes)</em></p>
  
  <pre><code>Provider=Sybase.ASEOLEDBProvider.2;Driver={SYBSE ASE ODBC Driver};Data Source=MyDataSource;Port=1234;Database=MyDatabase;uid=MyUser;pwd=MyPassword
  </code></pre>
  
  <p>But it is causing the error: <strong>Provider cannot be found. It may not be properly installed.</strong></p>
  
  <p>Here's some system info that you may need to determine the cause of the issue:</p>
  
  <ul>
  <li>Script will be run on 64-bit Windows 7 machine</li>
  <li>I have successfully connected to this Sybase database using MS Access</li>
  <li>I have installed the Sybase ASE ODBC Driver (32-bit) version 03.50.0010</li>
  <li>I have confirmed that it is installed and working by going to <em>C:\Windows\SysWOW64\odbcad32.exe</em> and located the drivers there</li>
  <li>The database is a System DSN (not a User DSN)</li>
  <li>Sybase Open Client version 10.0.4 </li>
  </ul>
  
  <p>The issue seems to be with the <code>Provider=</code> part of the connection string. It's worth noting here that as soon as I take away the <code>Provider=</code> part, I get this error: <strong>The specified DSN contains an architecture mismatch between the Driver and Application</strong>. So this leads me to believe that there is a 32-bit and 64-bit mismatch here. I've researched this and it turns out the way to fix it is to add a <code>Provider=</code> to your connection string to somehow specify which one to use. Here is a list of the Providers I've tried in the connection string:</p>
  
  <ul>
  <li>Sybase ASE OLE DB Provider</li>
  <li>Sybase.ASEOLEDBProvider</li>
  <li>ASEOLEDB</li>
  <li>ASEOLEDB.1</li>
  <li>Sybase.ASEOLEDBProvider.2</li>
  <li>Sybase</li>
  <li>Advantage OLE DB Provider</li>
  </ul>
  
  <p>All of these throw the same error. What am I missing here? </p>
  
  <hr>
  
  <p><strong>EDIT:</strong> As per your suggestions I have made some revisions to the script and have been able to push past the initial error, but now I get a completely different error. Here's the script as it is now</p>
  
  <pre><code>Dim connStr, objConn
  
  DataSource = "ICCM_PREVIEW"
  ServerIP = "1.2.3.4"
  Port = "1234" 
  DBuser = "myUser" 
  DBpwd = "myPassword" 
  DBName = "myDatabase" 
  Driver = "SYBASE ASE ODBC Driver"
  
  connStr = ""
  connStr = connStr &amp;"Driver="&amp; Driver &amp;";"
  connStr = connStr &amp;"Data Source="&amp; DataSource &amp;";"
  connStr = connStr &amp;"Srvr="&amp; ServerIP &amp;","&amp; Port &amp;";"
  connStr = connStr &amp;"Database="&amp; DBName &amp;";"
  connStr = connStr &amp;"uid="&amp; DBuser &amp;";"
  connStr = connStr &amp;"pwd="&amp; DBpwd &amp;";"
  
  Wscript.Echo connStr 
  
  'Define object type
  Set objConn = CreateObject("ADODB.Connection")
  
  'Open Connection
  objConn.open connStr
  </code></pre>
  
  <hr>
  
  <p>Here is the error message I get now, but I have no idea how to get past this one:</p>
  
  <pre><code>Microsoft OLE DB Provider for ODBC Drivers: [SYBASE][ODBC Sybase driver][Sybase]ct_connect(): user api layer: internal Client Library error: HAFAILOVER:Trying to connect to server
  </code></pre>