오늘은 지난 소스를 보던 중 괜찮은 부분이 눈에 띄어 또 써먹을 곳이 있지 않을까 하여 Posting 해 봅니다.
인터넷 어디선가 Copy 해온 소스인 것 같기도하고... (제가 만들었을리가... ^^;)
다른 곳에서 유사한 소스를 분이 계시다면... 알려주셔요... Link 를 걸도록 하겠습니다.

이 글을 보시는 분들께서도 필요하신 분이 있지 않을까 하는... ^^

    1 

    2     Private Function GetValueString(ByVal obj As Object) As String

    3         If (IsDBNull(obj)) Then Return "NULL"

    4 

    5         Select Case obj.GetType.FullName

    6 

    7             Case "System.Boolean"

    8                 If (obj = True) Then

    9                     Return "True"

   10                 Else

   11                     Return "False"

   12                 End If

   13 

   14             Case "System.String"

   15                 Dim str As String = obj

   16                 Return "N'" + str.Replace("'", "''") + "'"

   17 

   18             Case "System.DateTime"

   19                 Return "'" + obj.ToString() + "'"

   20 

   21             Case "System.Drawing.Image"

   22                 Return "NULL"

   23 

   24             Case "System.Drawing.Bitmap"

   25                 Return "NULL"

   26 

   27             Case "System.Byte[]"

   28                 Return "0x" + GetHexString(obj)

   29 

   30             Case Else

   31                 Return obj.ToString()

   32 

   33         End Select

   34     End Function

   35 

   36     Private Function GetHexString(ByRef bytes() As Byte) As String

   37         Dim sb As New System.Text.StringBuilder

   38         Dim b As Byte

   39         Dim i As Integer = 0

   40 

   41         For Each b In bytes

   42             i += 1

   43             sb.Append(b.ToString("X2"))

   44             If i > 10 Then

   45                 Return sb.ToString()

   46             End If

   47         Next

   48 

   49         Return sb.ToString()

   50     End Function



행복한 고수되셔요...


woojja ))*
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
반응형

+ Recent posts