0

I'm trying to figure out how this code works because its from VB6 and I am converting it to VB.NET, The previous developer of this program told me that the lstrvalue is an SQL code but I don't see any common statement like SELECT, UPDATE, etc. that is why I don't understand it.

rs.Open "Select AccountCode,rtrim(type) as type, rtrim(left(formula,3)) as bet1,ltrim(right(formula,3))as bet2 from vwTempTableWP where rtrim(type) in('SUM','+','-') order by orderby", con
If rs.EOF Then
Else
    rs.MoveFirst

    Do While rs.EOF <> True

        codetype = Trim(rs!AccountCode)
        tipo = Trim(rs!Type)
        bet1 = CDbl(Trim(rs!bet1))
        bet2 = CDbl(Trim(rs!bet2))

        If tipo = "SUM" Then
            lstrValue = "execute sp_sum '" & Trim(codetype) & "','Working'," & CDbl(bet1) & "," & CDbl(bet2) & ""
            con.Execute lstrValue
            'Do While con.State = adStateExecuting
            'Loop
        ElseIf tipo = "+" Then
            lstrValue = "execute sp_add '" & Trim(codetype) & "','" & Trim(report) & "'," & CDbl(bet1) & "," & CDbl(bet2) & ""
            con.Execute lstrValue
            'Do While con.State = adStateExecuting
            'Loop
        ElseIf tipo = "-" Then
            lstrValue = "execute sp_minus '" & Trim(codetype) & "','" & Trim(report) & "'," & CDbl(bet1) & "," & CDbl(bet2) & ""
            con.Execute lstrValue
            'Do While con.State = adStateExecuting
            'Loop
        End If
        rs.MoveNext
    Loop
    rs.Close
End If
  • rs is defined as new ADODB.Recordset

  • con is defined as new ADODB.Connection

1 Answer 1

1

The code you've posted is building SQL statements to execute a stored procedure, specifically one of sp_sum, sp_add, or sp_minus. Your SQL Server documentation should explain what a stored procedure is, and examination of the source for them in SQL Server Management Studio should show you what each of them does.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.