My FAQ,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 登陆资料
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 未整理篇 | 技术讨论
解决一个.NET联接SQL的问题
作者:yiyang 时间:2002-01-26 12:13 出处:互联网 责编:MyFAQ
              摘要:解决一个.NET联接SQL的问题

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

 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 myfaq.com.cn All rights reserved. www.myfaq.com.cn 版权所有