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

📄 dbutility.vb

📁 使用Access数据库演示的任务分配管理程序 一个使用ADO.NET基于Microsoft Access数据库演示的任务分配管理的程序
💻 VB
字号:
'------------------------------------------------------------------------------
' <auto-generated>
'     This code was generated by a tool.
'     Runtime Version:2.0.50727.42
'
'     Changes to this file may cause incorrect behavior and will be lost if
'     the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------

Option Strict Off
Option Explicit On

Imports Microsoft.VisualBasic
Imports Microsoft.VisualBasic.Information
Imports System

'*************************************************************
' Class Name:  dbUtility
' Purpose:  Class used to convert Null values
' Description: 
'***************************************************************
Namespace Database
    
    Public Class dbUtility
        
        Shared Function NullToZero(ByVal o As Object) As Double
            Dim IsInvalid As Boolean = false
            If (o Is Nothing) Then
                IsInvalid = true
            End If
            If (Convert.IsDBNull(o) = true) Then
                IsInvalid = true
            End If
            If (Information.IsNumeric(o) <> true) Then
                IsInvalid = true
            End If
            If (IsInvalid = true) Then
                Return 0
            Else
                Return Convert.ToDouble(o)
            End If
        End Function
        
        Shared Function NullToString(ByVal o As Object) As String
            Dim IsInvalid As Boolean = false
            If (o Is Nothing) Then
                IsInvalid = true
            End If
            If (Convert.IsDBNull(o) = true) Then
                IsInvalid = true
            End If
            If (IsInvalid = true) Then
                Return ""
            Else
                Return Convert.ToString(o)
            End If
        End Function
        
        Shared Function NullToDate(ByVal o As Object) As Date
            Dim IsInvalid As Boolean = false
            If (o Is Nothing) Then
                IsInvalid = true
            End If
            If (Convert.IsDBNull(o) = true) Then
                IsInvalid = true
            End If
            If (Information.IsDate(o) <> true) Then
                IsInvalid = true
            End If
            If (IsInvalid = true) Then
                Return New Date(1918, 1, 1)
            Else
                Return Convert.ToDateTime(o)
            End If
        End Function
        
        Shared Function NullToBool(ByVal o As Object) As Boolean
            Dim IsInvalid As Boolean = false
            If (o Is Nothing) Then
                IsInvalid = true
            End If
            If (Convert.IsDBNull(o) = true) Then
                IsInvalid = true
            End If
            If (IsInvalid = true) Then
                Return false
            Else
                Return Convert.ToBoolean(o)
            End If
        End Function
        
        Shared Function NullToGuid(ByVal o As Object) As System.Guid
            Dim IsInvalid As Boolean = false
            If (o Is Nothing) Then
                IsInvalid = true
            End If
            If (Convert.IsDBNull(o) = true) Then
                IsInvalid = true
            End If
            If (IsInvalid = true) Then
                Return Guid.NewGuid
            Else
                Return CType(o,System.Guid)
            End If
        End Function
    End Class
End Namespace

⌨️ 快捷键说明

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