想请教的是VB中 如何写计算工资的问题
比如数据库为salary,表名为salary,要涉及的 是 单价和数量2个字段,窗体上有TEXT1,如何将总的金额在TEXT1中显示出来,请教!请教!急!~~(得团团转......)

解决方案 »

  1.   

    dim conn as new adodb.connection
    dim rs as new adodb.recordset
    conn.connectionstring="..."    '与数据库的连接语句
    conn.open
    if rs.state=adstaetopen then rs.close
    rs.open "select fnum,fprice,fnum*fprice as fmoney from salary",conn,adopenkeyset,adlockreadonly
    if rs.recordcount>0 then
        text1.text=format(rs!fmoney,"###0.00")
    end if
    rs.close
    set rs=nothing'如果记录集有多行,则可用msflexgrid控件来显示数据
    rs.open "select fnum,fprice,fnum*fprice as fmoney from salary",conn,adopenkeyset,adlockreadonly
    set msflexgrid1.datasource=rs
    rs.closes
    set rs=nothing
      

  2.   

    dim conn as new adodb.connection
    dim rs as new adodb.recordset
    conn.connectionstring="..."    '与数据库的连接语句
    conn.open
    if rs.state=adstaetopen then rs.close
    不好意思,盗版楼上一下 ^-^
    总金额
    rs.open "select sum(单价 * 数量 ) as sum_price from salary",conn,adopenkeyset,adlockreadonly
    text1.text=format(rs!sum_price,"0.00")