您的位置:程序门 -> vb -> 基础类



帮我看一段代码谢谢了!!


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


帮我看一段代码谢谢了!!
发表于:2007-05-08 13:55:16 楼主
const   gstrconn   as   string   =   "provider=microsoft.jet.oledb.4.0;password= " " " ";user   id=admin;data   source=d:\jcxt.mdb;persist   security   info=false "

private   sub   cmd1_click()
        dim   strsql                     as   string
        dim   conn                         as   new   adodb.connection
        dim   rs                             as   new   adodb.recordset
        strsql   =   "   select   [riqi]   from   chuchaxt   where   [chuno]   =   ' "   &   text1.text   &   " ' "
        if   connectdb(conn,   gstrconn,   60)   <>   vbtrue   then   exit   sub
       
        rs.open   strsql,   conn,   adopenstatic
        if   not   rs.eof   then
                text2.text   =   rs.fields(0)
                text3.text   =   rs.fields(2)
        end   if
        rs.close
        set   conn   =   nothing
end   sub
public   function   connectdb(byref   conn   as   adodb.connection,   byval   strconnstring   as   string,   connectiontimeout   as   long)
        on   error   goto   moddb_connectdb_error
        set   conn   =   new   adodb.connection
        if   conn.errors.count   >   0   then
                set   conn   =   nothing
        end   if
                if   (connectiontimeout   <>   -1)   then
                conn.connectiontimeout   =   connectiontimeout
        end   if
        conn.open   strconnstring
        connectdb   =   vbtrue
        exit   function
moddb_connectdb_error:
        set   conn   =   nothing
        connectdb   =   vbfalse
end   function

为什么点cmd1时只能查询一个字段???谢谢了??
发表于:2007-05-08 14:06:011楼 得分:0
可以查询其他的  
你设置一个变量
发表于:2007-05-08 14:08:542楼 得分:0
strsql   =   "   select   [riqi]   from   chuchaxt   where   [chuno]   =   ' "   &   text1.text   &   " ' "

这个语句中你只查询了riqi这个字段啊

select   f1,f2,f3.....from   tb  
sql语句中列出你要查询的字段就ok了
发表于:2007-05-08 14:12:463楼 得分:0
............啊,我又理解错lz的意思了...
家人正解


快速检索

最新资讯
热门点击