Wrox Programmer Forums
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking 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 Basics 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
Old November 14th, 2007, 01:27 PM
Friend of Wrox
Join Date: Nov 2007
Posts: 207
Thanks: 2
Thanked 15 Times in 15 Posts
Default Response.BinaryWrite issue

I have an uploadfile using a c#.net that stores the image to a sql database type Image. i'm using vb.net to retrieve the image and display it. but when i use response.binarywrite it only displays System.byte[]

Here is my upload code using c#.net (this was an open source code i retrieved and not my own. I made modifications so i assume i did something wrong since i primarily use vb.net)

Stream imgStream = uploadFile.InputStream;
int imgLen = uploadFile.ContentLength;
string imgContentType = uploadFile.ContentType;
byte[] imgBinaryData = new byte[imgLen];
int n = imgStream.Read(imgBinaryData,0,imgLen);

SqlConnection sqlConn = new SqlConnection("Server=localserver;Database=Photos; Uid=blank;Pwd=blank;");
SqlCommand sqlComm = new SqlCommand("sp_Photos_InsertPhoto '" + UserID + "','" + Album + "','" + imgBinaryData + "'", sqlConn);

Here is my retrieval code using vb.net:

Dim oCN
Dim oRS

oCN = Server.CreateObject("ADODB.Connection")
oRS = Server.CreateObject("ADODB.Recordset")
oCN.Open(Session("Connection"), Session("SQLUser"), Session("SQLPassword"))
oRS = oCN.Execute("Select Photo from tblAlbums")

again the Response.BinaryWrite(oRS("Photo").value) yields System.Byte[] and not the picture.
Jason Hall

Follow me on Twitter @jhall2013
Old November 14th, 2007, 11:29 PM
Friend of Wrox
Join Date: Nov 2007
Posts: 207
Thanks: 2
Thanked 15 Times in 15 Posts

Nevermind I just converted the class to vb and now it's all working and much easier for me to work with.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Response.BinaryWrite hcweb Classic ASP Basics 0 June 20th, 2007 01:56 PM
i need a response to my q..:-) noor ASP.NET 1.0 and 1.1 Basics 1 January 14th, 2005 05:10 PM
BinaryWrite an image Bammer22 C# 2 March 3rd, 2004 02:14 AM
Response.Flush jeffm_22 Classic ASP Professional 1 October 20th, 2003 08:39 AM
NO PHP response mkoohian BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 5 October 12th, 2003 02:59 PM

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