Displaying image in image control
-
Can anybody tell me how to retrieve a image from ms access 2003 and bind it to image control.. i hv retrieved image successfully in a new page. But want to bind it to Image control. My code is as following : Uploading to Ms access // This code works fine Dim intImageSize As Int64 Dim strImageType As String Dim ImageStream As Stream intImageSize = File1.PostedFile.ContentLength strImageType = File1.PostedFile.ContentType ImageStream = File1.PostedFile.InputStream Dim ImageContent(intImageSize) As Byte Dim intStatus As Integer intStatus = ImageStream.Read(ImageContent, 0, intImageSize) Dim MyConnection As New Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("\MyDataBase.mdb") & "") Dim MyCommand As New Data.OleDb.OleDbCommand("INSERT INTO Images (ImageType,ImageData) VALUES (@ImgType,@img)", MyConnection) Dim prImageType As New Data.OleDb.OleDbParameter("@ImgType", 255) prImageType.Value = strImageType MyCommand.Parameters.Add(prImageType) Dim prImage As New Data.OleDb.OleDbParameter("@img", 255) prImage.Value = ImageContent MyCommand.Parameters.Add(prImage) MyConnection.Open() MyCommand.ExecuteNonQuery() MyConnection.Close() Retrieving Images from Msaccess Dim MyConnection As New Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("\MyDataBase.mdb") & "") Dim MyCommand As New Data.OleDb.OleDbCommand("Select * from Images", MyConnection) MyConnection.Open() Dim myDataReader As Data.OleDb.OleDbDataReader myDataReader = MyCommand.ExecuteReader() ' myDataReader = MyCommand.ExecuteReader(CommandBehavior.CloseConnection) Do While (myDataReader.Read()) 'Response.ContentType = myDataReader.Item("ImageType") 'Response.BinaryWrite(myDataReader.Item("ImageData")) Loop MyConnection.Close() Thanks..
-
Can anybody tell me how to retrieve a image from ms access 2003 and bind it to image control.. i hv retrieved image successfully in a new page. But want to bind it to Image control. My code is as following : Uploading to Ms access // This code works fine Dim intImageSize As Int64 Dim strImageType As String Dim ImageStream As Stream intImageSize = File1.PostedFile.ContentLength strImageType = File1.PostedFile.ContentType ImageStream = File1.PostedFile.InputStream Dim ImageContent(intImageSize) As Byte Dim intStatus As Integer intStatus = ImageStream.Read(ImageContent, 0, intImageSize) Dim MyConnection As New Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("\MyDataBase.mdb") & "") Dim MyCommand As New Data.OleDb.OleDbCommand("INSERT INTO Images (ImageType,ImageData) VALUES (@ImgType,@img)", MyConnection) Dim prImageType As New Data.OleDb.OleDbParameter("@ImgType", 255) prImageType.Value = strImageType MyCommand.Parameters.Add(prImageType) Dim prImage As New Data.OleDb.OleDbParameter("@img", 255) prImage.Value = ImageContent MyCommand.Parameters.Add(prImage) MyConnection.Open() MyCommand.ExecuteNonQuery() MyConnection.Close() Retrieving Images from Msaccess Dim MyConnection As New Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("\MyDataBase.mdb") & "") Dim MyCommand As New Data.OleDb.OleDbCommand("Select * from Images", MyConnection) MyConnection.Open() Dim myDataReader As Data.OleDb.OleDbDataReader myDataReader = MyCommand.ExecuteReader() ' myDataReader = MyCommand.ExecuteReader(CommandBehavior.CloseConnection) Do While (myDataReader.Read()) 'Response.ContentType = myDataReader.Item("ImageType") 'Response.BinaryWrite(myDataReader.Item("ImageData")) Loop MyConnection.Close() Thanks..
-
Can anybody tell me how to retrieve a image from ms access 2003 and bind it to image control.. i hv retrieved image successfully in a new page. But want to bind it to Image control. My code is as following : Uploading to Ms access // This code works fine Dim intImageSize As Int64 Dim strImageType As String Dim ImageStream As Stream intImageSize = File1.PostedFile.ContentLength strImageType = File1.PostedFile.ContentType ImageStream = File1.PostedFile.InputStream Dim ImageContent(intImageSize) As Byte Dim intStatus As Integer intStatus = ImageStream.Read(ImageContent, 0, intImageSize) Dim MyConnection As New Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("\MyDataBase.mdb") & "") Dim MyCommand As New Data.OleDb.OleDbCommand("INSERT INTO Images (ImageType,ImageData) VALUES (@ImgType,@img)", MyConnection) Dim prImageType As New Data.OleDb.OleDbParameter("@ImgType", 255) prImageType.Value = strImageType MyCommand.Parameters.Add(prImageType) Dim prImage As New Data.OleDb.OleDbParameter("@img", 255) prImage.Value = ImageContent MyCommand.Parameters.Add(prImage) MyConnection.Open() MyCommand.ExecuteNonQuery() MyConnection.Close() Retrieving Images from Msaccess Dim MyConnection As New Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("\MyDataBase.mdb") & "") Dim MyCommand As New Data.OleDb.OleDbCommand("Select * from Images", MyConnection) MyConnection.Open() Dim myDataReader As Data.OleDb.OleDbDataReader myDataReader = MyCommand.ExecuteReader() ' myDataReader = MyCommand.ExecuteReader(CommandBehavior.CloseConnection) Do While (myDataReader.Read()) 'Response.ContentType = myDataReader.Item("ImageType") 'Response.BinaryWrite(myDataReader.Item("ImageData")) Loop MyConnection.Close() Thanks..
You write a http handler that takes the id of the image on the URL, reads it from the DB and streams out it's bytes. Then you use URLs pointing to that handler for the URL of your image control
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
You write a http handler that takes the id of the image on the URL, reads it from the DB and streams out it's bytes. Then you use URLs pointing to that handler for the URL of your image control
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
CG is absolutely correct i too did it in the same way
If You win You need not Explain............ But If You Loose You Should not be there to Explain......