473,378 Members | 1,066 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Display an image on Image Control from Database, asp.net 2.0 vb

how can i display an image on Image Control from Database, asp.net 2.0 vb?

please help me...


thank you for your reply...
Mar 29 '07 #1
2 6342
kenobewan
4,871 Expert 4TB
Welcome to the site. Here is an example:
Expand|Select|Wrap|Line Numbers
  1. Dim strImageID As String = Request.QueryString("ImageID") 'Request the value of ImageID 
  2.  
  3. Dim sqlConnection As New SqlConnection("your_sql_connection") 'Write your SQL connection here 
  4. Dim sqlCom As New SqlCommand("Select [Image], [ImageType] From tbl_images Where ([ImageID]='" & strImageID & "')", sqlConnection) 
  5.  
  6. Dim sqlDataReader As SqlDataReader 
  7.  
  8. sqlConnection.Open() 'Open Sqlconnection 
  9. sqlDataReader = sqlCom.ExecuteReader 'Execute the SQL command 
  10. While sqlDataReader.Read 
  11.     Response.BinaryWrite(sqlDataReader.Item("Image")) 'Writing the Image retrieved from the database 
  12.     Response.ContentType = sqlDataReader.Item("ImageType") 'Setting the type of the retrieved image 
  13. End While 
  14. sqlConnection.Close() 'Close Sqlconnection
Expand|Select|Wrap|Line Numbers
  1. Image1.ImageUrl = ReadImage(TextBox1.Text.Trim) 'Show the image from db
Expand|Select|Wrap|Line Numbers
  1. Function ReadImage(ByVal strID As String) 
  2.     Return ("readimage.aspx?ImageID=" & strID) 
  3. End Function
Apr 1 '07 #2
Welcome to the site. Here is an example:
Expand|Select|Wrap|Line Numbers
  1. Dim strImageID As String = Request.QueryString("ImageID") 'Request the value of ImageID 
  2.  
  3. Dim sqlConnection As New SqlConnection("your_sql_connection") 'Write your SQL connection here 
  4. Dim sqlCom As New SqlCommand("Select [Image], [ImageType] From tbl_images Where ([ImageID]='" & strImageID & "')", sqlConnection) 
  5.  
  6. Dim sqlDataReader As SqlDataReader 
  7.  
  8. sqlConnection.Open() 'Open Sqlconnection 
  9. sqlDataReader = sqlCom.ExecuteReader 'Execute the SQL command 
  10. While sqlDataReader.Read 
  11.     Response.BinaryWrite(sqlDataReader.Item("Image")) 'Writing the Image retrieved from the database 
  12.     Response.ContentType = sqlDataReader.Item("ImageType") 'Setting the type of the retrieved image 
  13. End While 
  14. sqlConnection.Close() 'Close Sqlconnection
Expand|Select|Wrap|Line Numbers
  1. Image1.ImageUrl = ReadImage(TextBox1.Text.Trim) 'Show the image from db
Expand|Select|Wrap|Line Numbers
  1. Function ReadImage(ByVal strID As String) 
  2.     Return ("readimage.aspx?ImageID=" & strID) 
  3. End Function
.


hi i did not get the result for this coding...
May 8 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: John Scott | last post by:
I am storing an image in an SQL database and have one field as an image datatype. I am also using a webservice to transport data. I want to be able to resize the image and pass back a thumbnail...
4
by: Kevin Myers | last post by:
Hello, Please forgive my reposting of this note with hopefully a more relevant subject line. On an Access 2000 form under Windows 2000 I would like to use a Kodak Image Edit Control to...
3
by: RAllsopp | last post by:
I have a client who would like to have several pictures associated with one system. I have read about storing only the pathname to save OLE overhead and have set-up a form for my client to...
12
by: Wadim Grasza | last post by:
I want to store and display (on a form or a report) multiple pictures per record in an access database. The pictures are not stored within the database. They are stored as files and the database...
1
by: Thubaiti | last post by:
Hi, I have an image web control with other web controls.. <asp:Image id="itemImage" runat="server"></asp:Image> <asp:Label id="itemNameLabel" runat="server"></asp:Label> <asp:Label...
0
by: chrispragash | last post by:
Hello Everybody, I have a server control that stores an image in the database as an image datatype. I would like to display this image (may be in an image control) along with other text in a...
5
by: Peter Lapic | last post by:
I have to create a image web service that when it receives an imageid parameter it will return a gif image from a file that has been stored on the server. The client will be an asp.net web page...
3
by: den 2005 | last post by:
Hi everyone, Here is code working on..Trying to insert record with a column with Image or VarBinary datatype in sql database from a existing jpeg image file, then retrieve this image from...
1
by: rh1200la | last post by:
Hey all. I'm trying to display a BLOB image from SQL Server to a .NET user control. I have found resources on the internet that say create a .aspx page and display at as content type image/gif. ...
2
by: smorrison64 | last post by:
I have a form that is coded to open a File Dialog boc to pick a picture to display on that particular item on a subform. My form is not based on query, but rather two separate tables (one primary,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.