title: Executing a Query in ADODB in VB6
body: <p>I have a program in Visual Basic 6 thats listens to a ComPort and generates SQL Querys based on the data it recieves. Im using ADODB as my Database link of choice. </p>
  
  <p>Currently im trying this:</p>
  
  <pre><code>' Initiate Database Connection
    Call dbConn
    results.Open SQLQueryfeld(s), cn
    Debug.Print (results.GetString)
    Debug.Print ("SQL Statement  " &amp; SQLQueryfeld(s) &amp; "  wurde erfolgreich ausgeführt")
    results.Close
  </code></pre>
  
  <p>Which gives me a "This operation is not permitted on a closed object" on the first Debug.Print line.</p>
  
  <p>dbConn is a public function that creates an ADODB connection object named cn
  results is initiated in the head of the function the code is from as</p>
  
  <pre><code>Dim results as New ADODB.Recordset
  </code></pre>
  
  <p>The end goal here is: Execute a INSERT sql statement (stored in string array SQLQueryfeld(s) ) and get a return wether or not it was successful. Im open to any other way of doing this, too, but it must use ADODB.</p>
  
  <p>Here is some other code from the same project that works fine:</p>
  
  <pre><code>    Call dbConn
  
  SQL = "SELECT Name FROM Personen WHERE Eintrag=" &amp; Personalid &amp; " "
  rs.Open SQL, cn
  
  If rs.RecordCount &gt; 0 Then
  tmp_name = rs.GetString
  tmp_name = Replace(tmp_name, Chr(13), "")
  tmp_name = Replace(tmp_name, Chr(10), "")
  tmp_name = Replace(tmp_name, vbCrLf, "")
  </code></pre>