📄 dbutility.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 + -