2015-04-07 71 views
0

我想弄明白這個代碼是如何工作的,因爲它從VB6和我將它轉換爲VB.NET,此程序的以前的開發人員告訴我,lstrvalue是一個SQL代碼,但我沒有看到像SELECT,UPDATE等常見語句,這就是爲什麼我不理解它。用SQL將VB6轉換爲VB.NET

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被定義爲新ADODB.Recordset

  • CON被定義爲新ADODB.Connection

回答

1

你張貼正在建設的SQL語句中的代碼執行stored procedure,特別是sp_sum,sp_addsp_minus之一。你的SQL Server文檔應該解釋什麼是存儲過程,並在SQL Server Management Studio中檢查它們的源代碼應該告訴你他們每個人做了什麼。