Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 6th, 2007, 03:58 AM
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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Text(Sql Server Text Field) to Image(JPG) srinivas72 ADO.NET 2 February 13th, 2009 06:31 PM
convert to string prafullaborade XML 7 May 29th, 2008 02:59 PM
Convert string to Date rprasad012 ASP.NET 1.0 and 1.1 Basics 1 March 19th, 2008 07:07 AM
Convert from Image to Text niallhannon SQL Server 2000 9 February 24th, 2007 02:17 PM
Convert String Date to Date for a SQL Query tdaustin Classic ASP Basics 4 July 7th, 2003 06:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.