Store two Queries result in third variable

后端 未结 3 373
名媛妹妹
名媛妹妹 2020-12-22 12:02

What\'s wrong with this code:

Visual Basic 6.0 With access 2007

Private Sub Command1_Click()
Dim Sell_tbl, Stock_Bottle, res As String


Sell_tbl =         


        
3条回答
  •  南笙
    南笙 (楼主)
    2020-12-22 13:07

    It is what I want....

    Private Sub Command2_Click()
    Dim con As New ADODB.Connection
    con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
         & App.Path & "\add_entry.mdb;Persist Security Info=False"
    
    Dim rs As New ADODB.Recordset
    Dim rs1 As New ADODB.Recordset
    Dim result_hold As Integer
    
    Dim large_tbl As String
    Dim sell_large As String
    large_tbl = "SELECT Sum(No_Of_Bottle) FROM add_cotton where Cateogry='Large'"
    sell_large = "SELECT Sum(Quantity) FROM Sell_Detail where Cateogry='Large'"
    
    rs.Open large_tbl, con, adOpenDynamic, adLockOptimistic
    rs1.Open sell_large, con, adOpenDynamic, adLockOptimistic
    
    result_hold = CInt(rs.Fields(0).Value) - CInt(rs1.Fields(0).Value)
    Text1.Text = CStr(result_hold)
    End Sub
    

    'if u need to retreive whole colum use loop or etc.. but one thing is remember to you two sources 'never attach with single grid...

提交回复
热议问题