vb.net code

C

chris

hi i have found some vb.net code to display a blob image on the browser.


Dim con As New SqlConnection("Server=server1;uid=sa;pwd=guest;database=db1")
Dim da As New SqlDataAdapter("Select * From table1", con)
Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da)
Dim ds As New DataSet
con.Open()
da.Fill(ds, "table1")
Dim myRow As DataRow
myRow = ds.Tables("table1").Rows(0)
Dim MyData() As Byte
MyData = myRow("logo")
Response.Buffer = True
Response.ContentType = "Image/JPEG"
Response.BinaryWrite(MyData)





this is the vb code that works fine. but i am writing a c# app and i need to
convert the above small piece of code to c#

byte[] Picture;
Picture = (dr["logo"]); //ERROR cannot convert from object to byte
Response.Buffer=true;
Response.ContentType = "Image/JPEG";
Response.BinaryWrite(Picture);

i dont understand what i am doing wrong?



thanx
 
M

Mattias Sjögren

this is the vb code that works fine. but i am writing a c# app and i need to
convert the above small piece of code to c#

byte[] Picture;
Picture = (dr["logo"]); //ERROR cannot convert from object to byte
Response.Buffer=true;
Response.ContentType = "Image/JPEG";
Response.BinaryWrite(Picture);

i dont understand what i am doing wrong?

Make it

Picture = (byte[])dr["logo"];



Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top