title: SQL Exception SQL0206: Column or global variable is not found
body: <p>I connected to the database, and want to get some data. However, got the SQL Exception said that SQL0206: Column or global variable ADDDATE not found.</p>
  <p>Here's the related code:</p>
  <pre class="lang-vb prettyprint-override"><code>Function ConnectToiSeries() As Boolean
          Dim conSQL As String
          conSQL = &quot;Provider = IBMDA400; Data Source = xxxxxxx; User ID = xxxxx; Password = xxxxxxx&quot;
          coniseries.ConnectionTimeout = 30
          coniseries.Open(conSQL)
          If coniseries.State &lt;&gt; ADODB.ObjectStateEnum.adStateOpen Then
              Console.WriteLine(&quot;Error, Try Again.&quot;)
              Return False
              Exit Function
          Else
              Console.WriteLine(&quot;Connected.&quot;)
              Return True
          End If
      End Function
  
  Function GetDocuments(ByRef ClientRS as Adodb.recordset) As Boolean
          Dim i As Integer
          Dim ClientID As String
          Dim AttachmentName As String
          Dim Status As String
          Dim AdditionalFile As String
          Dim SQLStm As String
  
          If CheckedListBox1.CheckedItems.Count &gt; 0 Then
          Dim s As String = &quot;&quot;
          For i = 0 To (CheckedListBox1.CheckedItems.Count - 1)
              s = s + &quot;No.&quot; &amp; (i + 1).ToString &amp; &quot;:&quot; &amp; CheckedListBox1.CheckedItems.Item(i).ToString &amp; ControlChars.CrLf
              MessageBox.Show(&quot;You are Choosing:&quot; &amp; ControlChars.CrLf &amp; s)
              Dim SQLStm As String
              SQLStm = &quot;Select APFIVCCLA.APP, APFIVCCLA.CLIENT, APFIVCCLA.CLIENTID, APFATTACH.ATTTYP, APFATTACH.ATTPATHNAM, APFIVCCLA.INCSPTDOC, APFATTACH.ADDDATE&quot; &amp;
              ControlChars.CrLf &amp; &quot;From CPASDLIB.APFATTACH, CPASDLIB.APFIVCCLA&quot; &amp; ControlChars.CrLf &amp;
              &quot;Where APFIVCCLA.App = 'Simple Legal' And APFIVCCLA.ATTKEY = '&quot; &amp; CheckedListBox1.CheckedItems.Item(i) &amp;
              &quot;' AND APFIVCCLA.Client = APFATTACH.ATTKEY And APFATTACH.ADDDATE = '&quot; &amp; Rundate &amp; &quot;'&quot; &amp; ControlChars.CrLf &amp; &quot; Order by APFIVCCLA.Client&quot;
              ClientRS.Open(SQLStm, coniseries)
  </code></pre>
  <p>The SQLStm sentences can be run, and can get results, but don't know why not work for this program.</p>
  <p>Here's the full Error Message:</p>
  <blockquote>
  <p>Exception thrown: 'System.Runtime.InteropServices.COMException' in
  SLBS.exe An unhandled exception of type
  'System.Runtime.InteropServices.COMException' occurred in SLBS.exe</p>
  <p>SQL0206: Column or global variable ADDDATE not found. Cause . . . . .
  :   ADDDATE was not found as a column of table *N in *N and was not
  found as a global variable in *N. If the table is *N, ADDDATE is not a
  column of any table or view that can be referenced. Recovery  . . . :
  Do one of the following and try the request again: -- Ensure that the
  column and table names are specified correctly in the statement. -- If
  this is a SELECT statement, ensure that all the required tables were
  named in the FROM clause. -- If the column was intended to be a
  correlated reference, qualify the column with the correct table
  designator. -- If the column was intended to be a global variable,
  qualify the name with the schema where the global variable exists or
  ensure the schema is in the path.</p>
  </blockquote>
  <p>Thanks.</p>