选取Text1和Text2里面比较大的数值,update给一个表里的某个的字段,语句怎么写?
Dim rs As New ADODB.Recordset
rs.Open "update authors set au_id='" & Trim(max Val(Text1.Text) or Val(Text2.Text)) &" ' where  au_lname='" & Text1.Text & "'"
上面的是错误的,请给个例子

解决方案 »

  1.   

    Trim(max Val(Text1.Text) or Val(Text2.Text))
    =============================================
    iif(x>y,x,y)
    ============================================= 
    au_id如果是数字不要单引号
      

  2.   

    按你说的,这样你看看,行不行,
    dim objCn as New Connection
    Dim rs As New ADODB.Recordset
    objCn.ConnectionString = "driver=SQL Server;server=(LOCAL);database=dt"
    objCn.Open
    rs.Open "select * from  表名 ", objCn, adOpenKeyset, adLockOptimistic
    rs.addnow
    if text1.text>text2.text then
      rs("au_lname")=text1.text
    else
      rs("au_lname")= text2.text
    end if 
    rs.update
    这是在SQL中,加入一个记录
      

  3.   

    rs("au_lname")= iif(val(text1.text)>val(text2.text),val(text1.text),val(text2.text))