Dim selectid As String
        Dim selectid1 As Long
        Dim selectid2 As Long
        selectid = Combo1.text
        selectid1 = Split(selectid, "-")(0)
        selectid2 = Split(selectid, "-")(1)
        Dim ID_Rs As ADODB.Recordset
        SQL = "select id,uid,content,dd,title,rs,dc,ishead,dirhead,isgbook,issign,auid,cword,dy_type,trackback,comments,filetp,isubb,isphone from diary where id between selectid1 and selectid2 and uid='" & uId & "' and islocked is null"
        SQL = "execute user_diary_tag '" & Replace(SQL, "'", "''") & "'"
        Set ID_Rs = Conn.Execute(SQL)
combo1是个复合框,包含的值为1-499999,500000-699999,我采用类型转换,再通过split函数获取“-”前后的值,然后传给SQL语句查询,取的值是对的,但是程序运行的话提示错误:提示selectid1无效,这是怎么回事啊?

解决方案 »

  1.   

    我发现了:SQL = "select id,uid,content,dd,title,rs,dc,ishead,dirhead,isgbook,issign,auid,cword,dy_type,trackback,comments,filetp,isubb,isphone from diary where id between selectid1 and selectid2 and uid='" & uId & "' and islocked is null"这句话有问题,错误出在id between selectid1 and selectid2 提示列表selectid1无效,因为我要把查询的ID区间设置在selectid1和selectid2之间,朋友帮帮忙
      

  2.   

    id between '"& selectid1 &"' and '"& selectid2 &"'
      

  3.   

    SQL = "select id,uid,content,dd,title,rs,dc,ishead,dirhead,isgbook,issign,auid,cword,dy_type,trackback,comments,filetp,isubb,isphone from diary where id between" & selectid1 & " and " &  selectid2 & " and uid='" & uId & "' and islocked is null"
      

  4.   

    好象要这样吧
    dim selectid1
    selectid1 = Split(selectid, "-")"id between '"& cstr(selectid1(0)) &"' and '"& cstr(selectid1(1)) &"'"