SQL Server, Images and DataGrid in ASP.NET

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2006
Posts: 19
Reputation: postmaster is an unknown quantity at this point 
Solved Threads: 1
postmaster postmaster is offline Offline
Newbie Poster

SQL Server, Images and DataGrid in ASP.NET

 
0
  #1
Aug 20th, 2006
How to upload Images to SQL Server database using ASP.NET tools.
Also how to retrieve those saved images from SQL Server and display them onto DataGrid.
Visit: http://www.programmingknowledge.com/ImageUpload.aspx
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 84
Reputation: web_developer is an unknown quantity at this point 
Solved Threads: 1
web_developer web_developer is offline Offline
Junior Poster in Training

Re: SQL Server, Images and DataGrid in ASP.NET

 
0
  #2
Aug 23rd, 2006
u want to store the images in the database

if that wht u want to do, i dont suggest that

instead i will tell u to store the file path in a table in the database and then when u want to view the image u select its path from the database.

that wht i will do
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 47
Reputation: ChimpusDupus is an unknown quantity at this point 
Solved Threads: 0
ChimpusDupus ChimpusDupus is offline Offline
Light Poster

Re: SQL Server, Images and DataGrid in ASP.NET

 
0
  #3
Aug 29th, 2006
Image data is stored on a SQL database as binary data, and must be read as such. In order to create this DataGrid, you will need the page that it is on, say Default.aspx and another page to gather and display the image, say IMG.aspx. First look at IMG.aspx:

We need to read the binary data and output it within the page. We also need something to tell us what the id of the picture is in our database table. For this we will create a query in our URL. So the url of each image will be .../IMG.aspx?ID=XX, XX being the images ID. Then, in the code for that page, we gather the query value using Dim ImageID As Integer = Request.QueryString("ID")

Then you need to set up a SQL Connection, Command, and DataReader, read the binary data and then write it to the page:
  1.  
  2. Dim iConn As New Data.SqlClient.SqlConnection("-Connection String Here-")
  3. Dim iCmd As New Data.SqlClient.SqlCommand("SELECT image FROM IMAGES WHERE image_id = " & ImageID, iConn)
  4. Dim iRead As Data.SqlClient.SqlDataReader
  5.  
  6. iConn.Open()
  7. iRead = iCmd.ExecuteReader()
  8. Response.BinaryWrite(iRead("image"))
  9. iConn.Close()

Then, on Default.aspx, you add the datagrid and, instead of reading the binary data for the image from the database, you read the images ID, and add that to the url for the IMG.aspx page, which you then databind to an image or imagebutton's imageurl property.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 19
Reputation: postmaster is an unknown quantity at this point 
Solved Threads: 1
postmaster postmaster is offline Offline
Newbie Poster

Re: SQL Server, Images and DataGrid in ASP.NET

 
0
  #4
Sep 14th, 2006
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC