⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clsdataaccess.vb

📁 vb2005电子书籍——vb.net项目开发宝典源码
💻 VB
字号:

Imports System.Data.SqlClient


Namespace wsbgxt
    Public Class clsDataSet
        Private sdaO As SqlDataAdapter
        Private lsSQL As String, lsName As String
        '***********************************************************************
        'Class : Display and Update Data from DataSet in only one table
        '***********************************************************************


        '----------------------------------------------
        'Display DataSet from SQL Sentence through sqlDataAdapter
        Public Function CreateDataSet(ByVal strSQL As String, ByVal strName As String) As DataSet
            Dim dsTemp As New DataSet()
            Dim scnnNW As SqlConnection
            lsSQL = strSQL : lsName = strName
            If strName = "" Then lsName = "Table"
            PublicMod.ConnectDB(scnnNW)
            If scnnNW Is Nothing Then
                Return Nothing
            End If
            Try
                sdaO = New SqlDataAdapter(lsSQL, scnnNW)
                Dim scbP As New SqlCommandBuilder(sdaO)
                sdaO.Fill(dsTemp, lsName)
                PublicMod.DisConnect(scnnNW)
            Catch sqlex As SqlException
                PublicMod.LogException(sqlex)
                dsTemp = Nothing
                PublicMod.DisConnect(scnnNW)
            End Try
            Return dsTemp
        End Function


        '----------------------------------------------
        'Update DataSet through sqlDataAdapter,must Send the DataSet
        Public Function UpdateDataSet(ByRef inDS As DataSet) As Boolean
            If inDS Is Nothing Then
                Exit Function
            End If
            If lsName = "" Then lsName = "Table"
            'Dim lll As Integer = inDS.Tables(lsName).Rows.Count
            ' Dim r As DataRow = inDS.Tables(lsName).Rows(lll - 1)
            Try
                If (sdaO Is Nothing) Then
                    CreateDataSet(lsSQL, lsName)
                End If
                inDS.EnforceConstraints = False
                sdaO.Update(inDS, lsName)
                Return True
            Catch sqlex As SqlException
                PublicMod.LogException(sqlex)
                Return False
            End Try
        End Function

    End Class


 
End Namespace

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -