I have a small issue, I am trying to code a Macro for Autocad in VBA.
I am trying to read a certain column value through sending a SQL native query that connects to the database server.
The problem is that my String variable descToReturn  that's going to hold a value of that column is returning null. I can't seem to figure out where I am wrong. So if anyone can advise that'd be great. 
Here's the code below:
Private Sub btnDuplicate_Click()
    Dim cnn As ADODB.Connection
    Dim rst As ADODB.Recordset
    Dim ConnectionString As String
    Dim StrQuery As String
    Dim BOMLineToCheck As AcadBlockReference
    Dim BOMAttributes As Variant
    Dim partNoToCheck As String
    Dim i As Integer
    Dim descToReturn As String
    ConnectionString = "Provider=SQLxxxxx.1;Password=xxxx;Persist Security Info=True;User ID=xxxx;Data Source=xx\xx;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Use Encryption for Data=False;Tag with column collation when possible=False;Initial Catalog=xxx_xxx"
    Set cnn = New ADODB.Connection
    cnn.ConnectionString = ConnectionString
    cnn.Open
    'cnn.CommandTimeout = 900
    Set rst = New ADODB.Recordset
    StrQuery = "SELECT * FROM [My Table Name] WHERE [My Column]='partNoToCheck'"
    For Each BOMLineToCheck In ThisDrawing.ModelSpace
        If BOMLineToCheck.Name = "BOM3LINE_old" Then
            BOMAttributes = BOMLineToCheck.GetAttributes()
            For i = 0 To UBound(BOMAttributes)
                If BOMAttributes(i).TagString = "PART#" Then
                    partNoToCheck = BOMAttributes(i).TextString
                End If
            Next i
        End If
        rst.Open StrQuery, cnn, adOpenDynamic
        With rst
            If Not .EOF Then
                descToReturn = rst![My Coulmn]                   
            End If
        End With
        rst.Close
        MsgBox descToReturn
    Next
End Sub
 
     
    