欢迎光临
我们一直在努力

建站超值云服务器,限时71元/月

解决一个.net联接sql的问题    yiyang(转贴)  
  
关键字     .net
  
出处     http://ouynagouyang
  

imports system.data
imports system.data.sqlclient
imports system.data.sqlclient.sqlexception
public class connect
    private s as string
    private s1 as string
    public connect as new sqlconnection("server=yiyang;database=kderp;uid=sa;password=123")
    sub new()
        connect.open()
    end sub
    public property sql()
        get
            return s
        end get
        set(byval value)
            s = value
        end set
    end property
    public property table()
        get
            return s1
        end get
        set(byval value)
            s1 = value

    end property
    public function retable() as datatable

        dim com as new dataset()

        dim ada as new sqldataadapter()
        dim com1 as new sqlcommand()
        com1.connection = connect
        com1.commandtext = s
        ada.selectcommand = com1
        ada.fill(com, "t1")
        return com.tables(0)

    end function
    public function exec() as integer
        dim i as integer

        dim com as new sqlcommand()
        com.commandtext = s
        com.connection = connect
        i = com.executenonquery()
        return i
    end function
    public function retdataset(byval t as string) as dataset

        dim com as new sqlcommand()
        com.connection = connect
        com.commandtext = s
        dim ada as new sqldataadapter()
        ada.selectcommand = com
        dim da as new dataset()
        ada.fill(da, t)
        return da
    end function
    public function retdataread() as sqldatareader

        dim com as new sqlcommand()
        com.connection = connect
        com.commandtext = s
        return com.executereader
    end function
end class

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 »
分享到: 更多 (0)

相关推荐

  • 暂无文章