View Single Post
 
Old October 6th, 2007, 03:58 AM
Maxxim Maxxim is offline
Friend of Wrox
 
Join Date: Mar 2006
Location: , , Portugal.
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default help me convert sql.image into string

Hello!
I have this problem from to much time!

I need to generate an sql insert file, in order to upload my db data.

I have this code:

Code:
Private Shared Function setParamterTypeAndValue(ByVal table As String, ByVal dr As SqlDataReader, ByVal col As Integer, ByVal sqlProviderType As String, ByVal colName As String) As String
            Dim result As String = ""
            If (sqlProviderType.ToString = "Int") Or _
            (sqlProviderType.ToString = "SmallInt") Then
                If (dr(col) Is DBNull.Value) Then
                    result += "NULL, "
                Else
                    result += CType(dr(col), String) & ", "
                End If
            ElseIf (sqlProviderType.ToString = "TinyInt") Then
                If (dr(col) Is DBNull.Value) Then
                    result += "NULL, "
                Else
                    result += CType(dr(col), Byte).ToString
                End If
            ElseIf (sqlProviderType.ToString = "VarChar") Or _
                    (sqlProviderType.ToString = "NVarChar") Or _
                    (sqlProviderType.ToString = "NChar") Or _
                    (sqlProviderType.ToString = "Char") Or _
                    (sqlProviderType.ToString = "NText") Or _
                    (sqlProviderType.ToString = "Text") Then
                If (dr(col) Is DBNull.Value) Then
                    result += "NULL, "
                Else
                    result += "'" & Replace(CType(dr(col), String), "'", "#180;") & "', "
                End If
            ElseIf (sqlProviderType.ToString = "Image") Then
                If (dr(col) Is DBNull.Value) Then
                    result += "NULL, "
                Else
                    Dim b As Byte() = CType(dr(col), Byte())
                    Dim str As String = Convert.ToString(b)
                    result += str & ", "
                End If
              ...
My big problem is when sqlprovidertype is Image/Binary!
Like the field "PropertyValuesBinary" from "aspnet_Profile" table!
With this code I return something like "...xxxx' , System.Byte[], 'blabla..."

If anyone could help me I'll be very grateful
Max