BinaryWrite

Jun 2, 2004

I succesfully uploaded various file into my SQL database. My question is, does anyone know how to retrieve or display these files such as jpg, word document.... in VB.net

View 1 Replies


ADVERTISEMENT

Error Using Linq Response.BinaryWrite For Images Stored In The Database

Mar 1, 2008

 
 hi i have given you the ado.net code to retrive a image from the database.
I have tried using linq and i am getting a error in
Response.BinaryWrite(rs.image) in LINQ.
so i have used the ado.net which i dont want to use.
can you pls help me how to correct the error.it says cannot convert linq.binary data...
thanks
 Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MyReader As SqlDataReaderDim MySqlConnection As SqlConnection
Dim MySqlCommand As SqlCommandMySqlConnection = New SqlConnection("server=(local)SQLExpress;Integrated Security=SSPI;database=customs")MySqlCommand = New SqlCommand("select * from tbl_temp_importer_owner where TIN=555", MySqlConnection)
 
MySqlConnection.Open()
MyReader = MySqlCommand.ExecuteReader()Do While (MyReader.Read())
Response.ContentType = MyReader.Item("PersonImageType")Response.BinaryWrite(MyReader.Item("PersonImage"))///Error come here in linq
Loop
MySqlConnection.Close()Response.Write("Person info successfully retrieved!")
 
End Sub

View 4 Replies View Related

Read Text File From SQL Server, Read Its Content, And Load It In RichTextBox (Related Component: Context.Response.BinaryWrite(), And StreamReader)

Nov 26, 2007

OBJECTIVE: I would like to read a text file from SQL Server 2000, read the text file content, and load its conntents in a RichTextBoxTHINGS I'VE DONE AND HAVE WORKING:1) I've successfully load a text file (ex: textFile.txt) in sql server database table column (with datatype Image) 2) I've also able to load the file using a Handler as below: using System;using System.Web;using System.Data.SqlClient;public class HandlerImage : IHttpHandler {string connectionString;public void ProcessRequest (HttpContext context) {connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["NWS_ScheduleSQL2000"].ConnectionString;int ImageID = Convert.ToInt32(context.Request.QueryString["id"]);SqlConnection myConnection = new SqlConnection(connectionString);string Command = "SELECT [Image], Image_Type FROM Images WHERE Image_Id=@Image_Id";SqlCommand cmd = new SqlCommand(Command, myConnection);cmd.Parameters.Add("@Image_Id", System.Data.SqlDbType.Int).Value = ImageID;SqlDataReader dr;myConnection.Open(); cmd.Prepare(); dr = cmd.ExecuteReader();if (dr.Read()){ //WRITE IMAGE TO THE BROWSERcontext.Response.ContentType = dr["Image_Type"].ToString();context.Response.BinaryWrite((byte[])dr["Image"]);}myConnection.Close();}public bool IsReusable {get {return false;}}}'>'>
<a href='<%# "HandlerDocument.ashx?id=" + Eval("Doc_ID") %>'>File
</a>- Click on this link, I'll be able to download or view the file WHAT I WANT TO DO, BUT HAVE PROBLEM:- I would like to be able to read CONTENT of this file and load it in a string as belowStreamReader SR = new StreamReader()SR = File.Open("File.txt");String contentText = SR.Readline();txtBox.text = contentText;BUT THIS ONLY WORK FOR files in the server.I would like to be able to read FILE CONTENTS from SQL Server.PLEASE HELP. I really appreciate it.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved