Run time error '91' when using MSSql
<p>I'm making a program in which I have to check some column values in another table before trying to save values in a different table.. both tables are in SQL. </p>

<p>I tried my best to do it myself but I get the error near the highlighted line. </p>

<p><code>rs.open(insert into testreport_tb1...</code></p>

<pre class="lang-vb prettyprint-override"><code>Private Sub Command1_Click()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim BrdSrNo As String
Dim Result As Boolean
Dim machineName As String

machineName = Environ("computername")
' Ready objects for use.
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
BrdSrNo = BoardSrNo.Text
Result = False
' Connect.
cn.Open "{Here I give the connection string}"
' Fetch a recordset.
rs.Open "select * from testreport_tb1 where board_SrNo = '" &amp; BrdSrNo &amp; "' order by test_DateTime desc", cn, adOpenStatic, adLockReadOnly
' Display value, and total recordcount.
MsgBox rs.Fields(3)
MsgBox rs.Fields(8)
'MsgBox rs.RecordCount
stage_Status = rs.Fields(3)
stage_Id = rs.Fields(8)
rs.Close
cn.Close

If stage_Status = "C" Then
If stage_Id = "True" Then
rs.Open "insert into testreport_tb1 values('" &amp; BrdSrNo &amp; "',3,GETDATE(),'" &amp; Result &amp; "',NULL,'" &amp; machineName &amp; "',' KO ','A','D')", cn, adOpenDynamic, adLockBatchOptimistic
MsgBox "saved"
End If
End If
' Close and release objects.
rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing

End Sub
</code></pre>