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

📄 dataset2.vb

📁 Programming Web and Desktop Applications in ADO .NET and ASP .NET
💻 VB
📖 第 1 页 / 共 2 页
字号:
            Me.columnTelephone = New DataColumn("Telephone", GetType(System.String), Nothing, System.Data.MappingType.Element)
            Me.Columns.Add(Me.columnTelephone)
            Me.columnTennis = New DataColumn("Tennis", GetType(System.Boolean), Nothing, System.Data.MappingType.Element)
            Me.Columns.Add(Me.columnTennis)
            Me.Constraints.Add(New UniqueConstraint("Constraint1", New DataColumn() {Me.columnID}, true))
            Me.columnID.AutoIncrement = true
            Me.columnID.AllowDBNull = false
            Me.columnID.Unique = true
        End Sub
        
        Public Function NewFriendsRow() As FriendsRow
            Return CType(Me.NewRow,FriendsRow)
        End Function
        
        Protected Overrides Function NewRowFromBuilder(ByVal builder As DataRowBuilder) As DataRow
            Return New FriendsRow(builder)
        End Function
        
        Protected Overrides Function GetRowType() As System.Type
            Return GetType(FriendsRow)
        End Function
        
        Protected Overrides Sub OnRowChanged(ByVal e As DataRowChangeEventArgs)
            MyBase.OnRowChanged(e)
            If (Not (Me.FriendsRowChangedEvent) Is Nothing) Then
                RaiseEvent FriendsRowChanged(Me, New FriendsRowChangeEvent(CType(e.Row,FriendsRow), e.Action))
            End If
        End Sub
        
        Protected Overrides Sub OnRowChanging(ByVal e As DataRowChangeEventArgs)
            MyBase.OnRowChanging(e)
            If (Not (Me.FriendsRowChangingEvent) Is Nothing) Then
                RaiseEvent FriendsRowChanging(Me, New FriendsRowChangeEvent(CType(e.Row,FriendsRow), e.Action))
            End If
        End Sub
        
        Protected Overrides Sub OnRowDeleted(ByVal e As DataRowChangeEventArgs)
            MyBase.OnRowDeleted(e)
            If (Not (Me.FriendsRowDeletedEvent) Is Nothing) Then
                RaiseEvent FriendsRowDeleted(Me, New FriendsRowChangeEvent(CType(e.Row,FriendsRow), e.Action))
            End If
        End Sub
        
        Protected Overrides Sub OnRowDeleting(ByVal e As DataRowChangeEventArgs)
            MyBase.OnRowDeleting(e)
            If (Not (Me.FriendsRowDeletingEvent) Is Nothing) Then
                RaiseEvent FriendsRowDeleting(Me, New FriendsRowChangeEvent(CType(e.Row,FriendsRow), e.Action))
            End If
        End Sub
        
        Public Sub RemoveFriendsRow(ByVal row As FriendsRow)
            Me.Rows.Remove(row)
        End Sub
    End Class
    
    <System.Diagnostics.DebuggerStepThrough()>  _
    Public Class FriendsRow
        Inherits DataRow
        
        Private tableFriends As FriendsDataTable
        
        Friend Sub New(ByVal rb As DataRowBuilder)
            MyBase.New(rb)
            Me.tableFriends = CType(Me.Table,FriendsDataTable)
        End Sub
        
        Public Property Baseball As Boolean
            Get
                Try 
                    Return CType(Me(Me.tableFriends.BaseballColumn),Boolean)
                Catch e As InvalidCastException
                    Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
                End Try
            End Get
            Set
                Me(Me.tableFriends.BaseballColumn) = value
            End Set
        End Property
        
        Public Property CarType As String
            Get
                Try 
                    Return CType(Me(Me.tableFriends.CarTypeColumn),String)
                Catch e As InvalidCastException
                    Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
                End Try
            End Get
            Set
                Me(Me.tableFriends.CarTypeColumn) = value
            End Set
        End Property
        
        Public Property DoB As Date
            Get
                Try 
                    Return CType(Me(Me.tableFriends.DoBColumn),Date)
                Catch e As InvalidCastException
                    Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
                End Try
            End Get
            Set
                Me(Me.tableFriends.DoBColumn) = value
            End Set
        End Property
        
        Public Property email As String
            Get
                Try 
                    Return CType(Me(Me.tableFriends.emailColumn),String)
                Catch e As InvalidCastException
                    Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
                End Try
            End Get
            Set
                Me(Me.tableFriends.emailColumn) = value
            End Set
        End Property
        
        Public Property FirstName As String
            Get
                Try 
                    Return CType(Me(Me.tableFriends.FirstNameColumn),String)
                Catch e As InvalidCastException
                    Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
                End Try
            End Get
            Set
                Me(Me.tableFriends.FirstNameColumn) = value
            End Set
        End Property
        
        Public Property Gender As String
            Get
                Try 
                    Return CType(Me(Me.tableFriends.GenderColumn),String)
                Catch e As InvalidCastException
                    Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
                End Try
            End Get
            Set
                Me(Me.tableFriends.GenderColumn) = value
            End Set
        End Property
        
        Public Property Golf As Boolean
            Get
                Try 
                    Return CType(Me(Me.tableFriends.GolfColumn),Boolean)
                Catch e As InvalidCastException
                    Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
                End Try
            End Get
            Set
                Me(Me.tableFriends.GolfColumn) = value
            End Set
        End Property
        
        Public Property ID As Integer
            Get
                Return CType(Me(Me.tableFriends.IDColumn),Integer)
            End Get
            Set
                Me(Me.tableFriends.IDColumn) = value
            End Set
        End Property
        
        Public Property LastName As String
            Get
                Try 
                    Return CType(Me(Me.tableFriends.LastNameColumn),String)
                Catch e As InvalidCastException
                    Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
                End Try
            End Get
            Set
                Me(Me.tableFriends.LastNameColumn) = value
            End Set
        End Property
        
        Public Property Salary As Decimal
            Get
                Try 
                    Return CType(Me(Me.tableFriends.SalaryColumn),Decimal)
                Catch e As InvalidCastException
                    Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
                End Try
            End Get
            Set
                Me(Me.tableFriends.SalaryColumn) = value
            End Set
        End Property
        
        Public Property Spouse As String
            Get
                Try 
                    Return CType(Me(Me.tableFriends.SpouseColumn),String)
                Catch e As InvalidCastException
                    Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
                End Try
            End Get
            Set
                Me(Me.tableFriends.SpouseColumn) = value
            End Set
        End Property
        
        Public Property Telephone As String
            Get
                Try 
                    Return CType(Me(Me.tableFriends.TelephoneColumn),String)
                Catch e As InvalidCastException
                    Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
                End Try
            End Get
            Set
                Me(Me.tableFriends.TelephoneColumn) = value
            End Set
        End Property
        
        Public Property Tennis As Boolean
            Get
                Try 
                    Return CType(Me(Me.tableFriends.TennisColumn),Boolean)
                Catch e As InvalidCastException
                    Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
                End Try
            End Get
            Set
                Me(Me.tableFriends.TennisColumn) = value
            End Set
        End Property
        
        Public Function IsBaseballNull() As Boolean
            Return Me.IsNull(Me.tableFriends.BaseballColumn)
        End Function
        
        Public Sub SetBaseballNull()
            Me(Me.tableFriends.BaseballColumn) = System.Convert.DBNull
        End Sub
        
        Public Function IsCarTypeNull() As Boolean
            Return Me.IsNull(Me.tableFriends.CarTypeColumn)
        End Function
        
        Public Sub SetCarTypeNull()
            Me(Me.tableFriends.CarTypeColumn) = System.Convert.DBNull
        End Sub
        
        Public Function IsDoBNull() As Boolean
            Return Me.IsNull(Me.tableFriends.DoBColumn)
        End Function
        
        Public Sub SetDoBNull()
            Me(Me.tableFriends.DoBColumn) = System.Convert.DBNull
        End Sub
        
        Public Function IsemailNull() As Boolean
            Return Me.IsNull(Me.tableFriends.emailColumn)
        End Function
        
        Public Sub SetemailNull()
            Me(Me.tableFriends.emailColumn) = System.Convert.DBNull
        End Sub
        
        Public Function IsFirstNameNull() As Boolean
            Return Me.IsNull(Me.tableFriends.FirstNameColumn)
        End Function
        
        Public Sub SetFirstNameNull()
            Me(Me.tableFriends.FirstNameColumn) = System.Convert.DBNull
        End Sub
        
        Public Function IsGenderNull() As Boolean
            Return Me.IsNull(Me.tableFriends.GenderColumn)
        End Function
        
        Public Sub SetGenderNull()
            Me(Me.tableFriends.GenderColumn) = System.Convert.DBNull
        End Sub
        
        Public Function IsGolfNull() As Boolean
            Return Me.IsNull(Me.tableFriends.GolfColumn)
        End Function
        
        Public Sub SetGolfNull()
            Me(Me.tableFriends.GolfColumn) = System.Convert.DBNull
        End Sub
        
        Public Function IsLastNameNull() As Boolean
            Return Me.IsNull(Me.tableFriends.LastNameColumn)
        End Function
        
        Public Sub SetLastNameNull()
            Me(Me.tableFriends.LastNameColumn) = System.Convert.DBNull
        End Sub
        
        Public Function IsSalaryNull() As Boolean
            Return Me.IsNull(Me.tableFriends.SalaryColumn)
        End Function
        
        Public Sub SetSalaryNull()
            Me(Me.tableFriends.SalaryColumn) = System.Convert.DBNull
        End Sub
        
        Public Function IsSpouseNull() As Boolean
            Return Me.IsNull(Me.tableFriends.SpouseColumn)
        End Function
        
        Public Sub SetSpouseNull()
            Me(Me.tableFriends.SpouseColumn) = System.Convert.DBNull
        End Sub
        
        Public Function IsTelephoneNull() As Boolean
            Return Me.IsNull(Me.tableFriends.TelephoneColumn)
        End Function
        
        Public Sub SetTelephoneNull()
            Me(Me.tableFriends.TelephoneColumn) = System.Convert.DBNull
        End Sub
        
        Public Function IsTennisNull() As Boolean
            Return Me.IsNull(Me.tableFriends.TennisColumn)
        End Function
        
        Public Sub SetTennisNull()
            Me(Me.tableFriends.TennisColumn) = System.Convert.DBNull
        End Sub
    End Class
    
    <System.Diagnostics.DebuggerStepThrough()>  _
    Public Class FriendsRowChangeEvent
        Inherits EventArgs
        
        Private eventRow As FriendsRow
        
        Private eventAction As DataRowAction
        
        Public Sub New(ByVal row As FriendsRow, ByVal action As DataRowAction)
            MyBase.New
            Me.eventRow = row
            Me.eventAction = action
        End Sub
        
        Public ReadOnly Property Row As FriendsRow
            Get
                Return Me.eventRow
            End Get
        End Property
        
        Public ReadOnly Property Action As DataRowAction
            Get
                Return Me.eventAction
            End Get
        End Property
    End Class
End Class

⌨️ 快捷键说明

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