473,414 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Why does the ISingleResult return an array of bytes as a string?

I need the stored procedure to return the array of bytes instead of a string.

The error I am getting is: Unable to cast object of type System.Byte[] to type System.String.

Expand|Select|Wrap|Line Numbers
  1.         ISingleResult<spVTGetAttachmentSelectResult> Result = ava.GetAttachment(AttachmentID);
  2.  
  3.         foreach (spVTGetAttachmentSelectResult Pdf in Result)
  4.         {
  5.  
  6.             System.Text.UTF8Encoding Str = new System.Text.UTF8Encoding();
  7.  
  8.             string FileName  = Pdf.Attachment;
  9.  
  10.             string Extension = (Pdf.FileExtension).ToString();
  11.  
  12.             byte[] DocBuffer = Str.GetBytes(FileName);
  13.  
  14.         }
  15.  
The stored procedure:
Expand|Select|Wrap|Line Numbers
  1. ALTER PROCEDURE [dbo].[spVTGetAttachmentSelect] (@AttachmentID int)
  2. AS
  3. BEGIN
  4.  
  5.     SELECT     VehicleAttachments.Attachment, VehicleAttachments.FileExtension
  6.  
  7.     FROM       VehicleAttachments
  8.  
  9.     WHERE     (VehicleAttachments.AttachmentID =  @AttachmentID)    
  10.  
  11. END
  12.  
Aug 27 '10 #1
1 2295
Plater
7,872 Expert 4TB
Is spVTGetAttachmentSelectResult a custom class somewhere?
The problem could be with it.
I've never used ISingleResult before so I'm not sure how it is supposed to behave.

EDIT: Scratch that, is the error coming from this line:
string FileName = Pdf.Attachment;

Pdf.Attachment is probably already a byte[]
Aug 31 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Hari Prasad | last post by:
Hi, I am trying to convert a byte array to a string. I am using the possible ways but not getting the result. DatagramPacket dgram = new DatagramPacket(buf, buf.length); ByteArrayInputStream...
0
by: Marc van Boven | last post by:
I'm stuck with the following problem: My nusoap-client calls a server-function giveCombination(). The function giveCombination should return something like array( => array( 'a_id' => 6,...
4
by: songkv | last post by:
Hi, I am trying to reassign an array of char to a string literal by calling a function. In the function I use pointer-to-pointer since I want to reassign the "string array pointer" to the string...
4
by: Prabhu | last post by:
Hi, We are having problem in converting a byte array to string, The byte array has char(174), char(175), char(240), char(242) and char(247) as delimiters for the message. when we use...
6
by: Ricardo Quintanilla | last post by:
i have a code that sends data to a socket listening over as400 platform, the socket responds to me as a "byte array". then i need to convert the "byte array" into a string. the problem is that...
2
by: Dave | last post by:
Hi, I'm trying to convert a byte array to string --This works... System.BitConverter.ToString(bytes) "EB-55-79-20-18-B2-76-4D-85-0A-93-6B-97-33-31-B8" --This doesn't, but returns...
0
by: leekent | last post by:
I need to write an activeX object to be installed on client machine which will be called using vbscript in web pages. The activeX will be writen in C#, and I need to return an array of strings. I...
10
by: Raj | last post by:
I need a VB function to return array of collections like Private Type Employee empname as string address as string salary as integer deptno as integer End Type dim employees() as Employee
2
by: noagbodjivictor | last post by:
I'm filling an array with user input, I want an empty string to be returned when nothing is entered; ie return key hit twice... How do I do that?
1
by: Kurt Jakobsen | last post by:
Hello, I have a MySQL query that I want to perform in a utility (not page) class. This query should fill up an array of string's and then return the array to the calling class. The array will then...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.