title: Is there a limit to the query length being passed to ADODB?
body: <p>I am currently testing a framework that stores a SQL query in a cell on an excel workbook and then passes the cell value to a variable. This variable then gets executed through <code>rs.Open query, cn</code> where:</p>
  
  <pre class="lang-vb prettyprint-override"><code>Dim rs As ADODB.Recordset 
  Dim cn As ADODB.Connection 
  </code></pre>
  
  <p>and I have tried these for "query" :</p>
  
  <pre class="lang-vb prettyprint-override"><code>Dim query as String
  Dim query as Variant
  </code></pre>
  
  <p>or even playing with fixed length queries:</p>
  
  <pre class="lang-vb prettyprint-override"><code>Dim query as String * 9999
  </code></pre>
  
  <p>In playing with the output of the query string, it cuts off somewhere around 8000. Google is coming up short for me, so I am coming here for answers. Is there a specific limit to what a variable can pass to <code>recordset.Open()</code>?</p>
  
  <p>NB: The connection string I am using for this particular query is :
      ConnectionString = "User ID=User;Password=PW;Data Source=DB;Provider=OraOLEDB.Oracle" </p>
  
  <p>But if you know whether there is a system specific limit for Oracle, NetezzaSQL, or MS SQL Server (SQLOLEDB.1) please let me know. I will need to specify the limitations of each in order to define which new queries will need to be converted into stored procedures. </p>
  
  <p>Here is the essentials of the code:</p>
  
  <pre class="lang-vb prettyprint-override"><code>Sub RunQueryTable()
  
  Dim cn As ADODB.Connection
  Dim RS As ADODB.Recordset
  Dim iCols As Integer
  Dim DB As String, User As String, PW As String
  Dim SQLTable As Worksheet
  Dim ConnectionString as String
  Dim query As String 'Or Dim query As Variant 'Or Dim query As String * 9999
  Dim i As Long
  etc, etc.
  
  Set SQLTable = Sheet32
  Set cn = New ADODB.Connection
  Set RS = New ADODB.Recordset
  
  DB = _____
  User = ______
  PW = ____
  
  ConnectionString = "User ID=" &amp; User &amp; _
                     ";Password=" &amp; PW &amp; _
                     ";Data Source=" &amp; DB &amp; _
                     ";Provider=OraOLEDB.Oracle"
  
  query = SQLTable.Cells(i, 3).Text
  
  cn.Open (ConnectionString)
  RS.CursorType = adOpenForwardOnly
  RS.Open (query), cn
  
  For iCols = 0 To RS.Fields.count - 1
      Worksheets("Output").Cells(1, iCols + 1).Value = RS.Fields(iCols).Name
  Next
  Worksheets("Output").Cells(2, "A").CopyFromRecordset RS
  
  RS.Close
  cn.Close
  
  End Sub
  </code></pre>
  
  <p>The specific error I am getting from VBA is : "ORA-00923: FROM keyword not found where expected" because the query is getting cut off. </p>