-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: shanbluez_bdotnet
Message 3 in Discussion

Hi, As per the below code you can view the uploaded file in the browser as well ,i am 
attaching code to download the file to the local  
Dim myConnection As New 
SqlConnection(ConfigurationSettings.AppSettings("ConnectionString")) 
Dim myCommand As New SqlCommand("Select * from ImgTable where imageid=" & imgId, 
myConnection) 
Dim fs As FileStream 
myConnection.Open() 
Dim myDataReader As SqlDataReader 
myDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection) 
Do While (myDataReader.Read()) 
Response.ContentType = myDataReader.Item("imgtype") 
Response.BinaryWrite(myDataReader.Item("imageid")) 
Loop 
above code will display the image on the same page. 
if you want to write that file locally  
Dim fs As FileStream 
myConnection.Open() 
Dim myDataReader As SqlDataReader 
myDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection) 
Do While (myDataReader.Read()) 
Dim buffer() As Byte 
buffer = myDataReader.Item("imageid") 
If Not File.Exists("c:\temp\testing.bmp") Then 
fs = New FileStream("c:\temp\testing.bmp", FileMode.Create) 
fs.Write(buffer, 0, buffer.Length) 
fs.Close() 
End If 
this code will write file locally. 
thanks, 
shankar

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDOTNET/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to