ADO.net problem: i can not view image data for the rest of my table rows except the image for the first row but i can read all the other non image fields for all rows.

Hi i have a table with the following fields

  1. imgid............int
  2. imgdata........image
  3. imgtitle.........varchar(max)
  4. imgType........varchar(max)
  5. imgLength.....bigint
  6. incident_id.....int

i have no problem with uploading the image but viewing the uploaded image(s) in a gridview has caused me great pain. The probelm is i have two pages. page1 grabs the image to display and page2 has a gridview that displays the grabed image. I wanted to have an sql statement like

SELECT * FROM mytable WHERE incident_id=someValue.

IF i have 5 records in this table and i view page2 in the browser,  all the table fields  for all records are displayed correctly except for imgData which displys the imgData for the first record for all the records returned by my query. So the problem is, if i had 5 records in this table, only the imgData in first record will be displyed for the rest of the rows.

Below is the code for the pageload event in page1(which grabs the image).

  1. Protected
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
  • Try
  • Dim qr As String
  • 'pass incident number in query string whose image should be displayed
  • qr = Request.QueryString(
  • "id").ToString
  • Dim ds As New DataSet
  • Dim da As New SqlClient.SqlDataAdapter
  • Dim arrContent As Byte()
  • Dim dr As DataRow
  • Dim strSql As String
  • strSql =
  • "Select * from images Where incident_id=" & Request.QueryString("id")
  • Dim connString As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\safetydata.mdf;Integrated Security=True;User Instance=True"
  • da =
  • New SqlClient.SqlDataAdapter(strSql, connString)
  • da.Fill(ds)
  • dr = ds.Tables(0).Rows(0)
  • arrContent =
  • CType(dr.Item("imgData"), Byte())
  • Dim conType As String = dr.Item("imgType").ToString()
  • Response.ContentType = conType
  • Response.OutputStream.Write(arrContent, 0, dr.Item(
  • "imgLength"))
  • Response.End()
  • Catch ex As Exception
  • End Try
  • End Sub

     And here is the code in page2 which displays the image grabed in page1 above

    1. Protected
    Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
  • Dim q As String
  • q = Request.QueryString(
  • "id").ToString
  • Dim ds As New DataSet
  • Dim da As SqlClient.SqlDataAdapter
  • Dim strSQL As String
  • 'strSQL = "Select incident_id,imgId,imgTitle from images WHERE incident_id=" & q
  • strSQL =
  • "Select * from images WHERE incident_id=" & q
  • Dim connString As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=""|DataDirectory|\safetydata.mdf"";Integrated Security=True;User Instance=True"
  • da =
  • New SqlClient.SqlDataAdapter(strSQL, connString)
  • da.Fill(ds)
  • ds.Tables(0).Columns.Add(
  • "imgFile")
  • For Each tempRow As DataRow In ds.Tables(0).Rows
  • tempRow.Item(
  • "imgFile") = ("imgGrab.aspx?id=" & tempRow.Item("incident_id"))
  • Next
  • imgGrid.DataSource = ds
  • imgGrid.DataBind()
  • End Sub

    I badly need help with this problem or suggest a simpler approach to solving this.

     


    --------------------------------------------------
    No Project Too Eazy.
    --------------------------------------------------
    0
    Nick
    3/15/2007 7:42:25 AM
    asp.net.object-datasource 16182 articles. 0 followers. Follow

    1 Replies
    2778 Views

    Similar Articles

    [PageSpeed] 33

    0
    imran
    3/15/2007 10:36:20 PM
    Reply:

    Similar Artilces:

    Not able to read all image from DB except 1st image of row
    On the selection of value from dropdownlist, image is displayed in display page. Selectedvalue has many image in DB say 50+ but as per my query below it reads only 1st image of DB i.e.1st row of database. So do let me know where my code is gng wrong.  CODE VIEW OF DISPLAY PAGE:public string FormatURL(object strArgument)    {        return ("Read.aspx?Coins=" + strArgument);    } SOURCE VIEW OF DISPLAY PAGE:<asp:Image ID="Image1" runat="server" Height="80px" Width="80px...

    I want to select top 3 rows except the first from 4 rows of a Table. It should select from top 2 row,top3 row and top4 row.
     Hi, Let say I've 4 rows in a table. I want to select top 3 rows except the first from 4 rows of a Table. It should select from top 2 row,top3 row and top4 row. Thanks in advance Asghar Ali Mohammed http://www.aliwebdev.com(Web Designer and Developer)Do not forget to "MARK AS ANSWER" on the post that helped you. If you can use Linq, you can use Skip. http://msdn.microsoft.com/en-us/vcsharp/aa336757.aspxThanks, EdMicrosoft MVP - ASP/ASP.NET Hii dear..U can fire the Query select Top(3) from Table1 order by id desc.. "A conclusion is whe...

    Is having a trigger that inserts a row in Table 'A', when a row in same table is inserted by ADo.Net code?
    I want to insert a row for a Global user  in Table 'A' whenever ADO.Net code inserts a Local user row into same table. I recommended using a trigger to implement this functionality, but the DBA was against it, saying that stored proecedures should be used, since triggers are unreliable and slow down the system by placing unecessary locks on the table. Is this true OR the DBA is saying something wrong? My thinking is that Microsoft will never include triggers if they are unreliable and the DBA is just wanting to offload the extra DBA task of triggers to the programmer so that a s...

    .net Project can't find image? but the image is present!
    I've got an image in a directory called App_Data, App_Data is on the root of the project. Also i included the image into the project. The image is located in the App_Data directory. If i run the project i dón't see an Image.Its a red cross instead of an image.So i right click for the details:   http://localhost:49984/App_Data/image.jpgEverything is ok.so i made a copy of it and places this in my browser.I get this error: Server Error in '/' Application. HTTP Error 403 - Forbidden. Version Information: ASP.NET Development Server 8.0.0.0 Is thi...

    How to show Images 5 images per row (i.e. In Horizontol View) of datalist?
    HelloI want to show images in datalist in horizontal view such that when the images are more than 5 then a new row must be added and the 6th image must be shown in the new row and so on. i.e. I want datalist to show 5 images per row in horizontal view. How is it possible?Thanks use the below query. it will give you the 5 images per row.  with cte as(select *,row_number() over (order by imageID) as rn from Images)select c.image,c1.image,c2.image,c3.image,c4.imagefrom  cte cleft outer join cte c1 on c1.rn = c.rn + 1left outer join cte c2 on c2.rn = c.rn + 2left outer join cte c3 o...

    How can set an image from SystemDrawing.Image into WebControls.Image?
    I want directly to set an image from SqlServer to the webform. Do you know how to do it ? please tell me. In the window form I saw a method to set an image from SqlServer: byte[] imgData=(byte[])dr["PictureFile"] // dr is SqlDataReader when call data from SqlServer MemoryStream ms = new MemoryStream(imgData); PictureBox1.Image = System.Drawing.Image.FromStream(ms); ms.Close(); but I have not yet seen any method set an image from SqlServer to WebForm. Have you seen it please tell me, thanks. ...

    Can't get dw_1.Object.Data[row] for a row > 32768
    Is anyone aware of a problem with passing a row greater than MAX(integer) (32768) to dw_1.Object.Data[row]? I would appreciate a response. Jameel Abdo MCI Systemhouse. I understand that PB5 didn't support object notation for more than 32K rows. It was supposed to be fixed in PB6 (although I haven't confirmed it in PB6, myself). The object notation tended to be a tad flakey in PB5 too (poor null handling, etc.). Many developers decided to stick with the GetItem, SetItem in PB5 to avoid these problems. Jameel Stephen Abdo wrote: > Is anyone aware of a proble...

    display images from SQL Server image across intranet using ado.net filestream object
    folks  i recently attended an MCPD boot camp where they taught me to access and store images using SQL Server and the filestream object.  Previously i had (sensibly) used a file server and impersonation to copy files. Uploading works fine.  Viewing works fine in debug so i rolled out an app in my work where the pics are uploaded and viewed across the intranet. to my horror i realised (too late!) that whilst it works fine in debug, it does not work when published. now no one but me can access these pics and it is a night mare.  the only documentation i have found ...

    First Row, Next Row, Prior Row, Last Row
    I have a SQL Anywhere 7.0 Database, have a table Product_detail which contains Column Name Datatype width Null Default batch_id char(10) No None prod_id Integer No None employee_id Integer No None quantity Integer No None price Numeric (14, 2) No None Its primary key is batch_id I have a Freeform Datawindow with this table I want to provide the first row, next row, prior row and last row Ho...

    How can I put the images on a image?
    How can I put the images on a image? Is Layer should be set? Is True, how to do it? Can anyone solve my problem with example or codes? Thx very much What do you mean by "put the images on a image"?Microsoft MVP - Windows Live PlatformBlog: http://pietschsoft.com | Web.Maps.VE - ASP.NET AJAX Virtual Earth Control <IMG id="myImage" alt="Alternate text" src="myImage.gif"> Or, for server controls: <asp:Image id="myImage" runat="server" ImageUrl="myImage.gif"></asp:Image>...

    ReorderList image of row being dragged is behind row background
    I added a background colour to the table in my ReorderList Item Template and now the image of the row being dragged is behind the background colour. It can only be seen when the row being dragged is to the right of the other rows. RegardsMatthew ...

    Image button if fired, but there is a new issue. Help needed in displaying mutiple data in accordian style(using modal popup extender) when grid row is selected and image button is clicked
    Hi, I did work on server side code of image button without specfiying Modal Pop up target control id as imagebutton in aspx page, it throws error when registering the imagebutton in Grid selected Index changed event.. here is code vwbenftsBtn.Click += new EventHandler(this.vwbenftsBtn_Click); I am not sure why is it throwing error... Using the button instead of image button works fine.. we have a Masterpage with all the web application menus and other copyright stuff added and this page is referenced in all the pages. The issue is we have form tag defined in the Masterpage. For the mo...

    Can only set background image for every other row in thread pane
    A new add-on I'm working on is trying to set the background image for rows in the Thunderbird thread pane when the "enhanced-priority-display-highest" property set set on the row. I've got this in my CSS: treechildren::-moz-tree-row(enhanced-priority-display-highest) { background-image: url("background-highest.gif"); } This only works for half of the rows. I assume that this is because odd/even rows are styled differently. I tried creating two separate CSS blocks, one with " odd" and one with " even" in the properties. That di...

    how can i add row to table of sql with vb.net code?
    how can i add row to table of sql with vb.net code?  You can use System.Data.SqlClient classes :  Using con As New SqlConnection(" your connection string goes here ") Dim com As New SqlCommand("Insert into Person (id,name) values(@id,@name) ", con) com.Parameters.AddWithValue("@id", 1) com.Parameters.AddWithValue("@name", "Nomi1") com.Connection.Open...

    How can I store data in one row instead of 10 rows?
    Hi I have this stored procedure using Table Variable. ------------------------------------------------------------------------------------------------------------------------------- create procedure sp_matching @pid Int ASdeclare @tbl table (MAID int, image varchar(100)) insert @tblselect MAID, image from productswhere pid in (select top 10 mid from matching1 where pid=@pid order by newid()) select * from @tbl GO --------------------------------------------------------------------------------------------------------------------------------- When I run this sp, i have tabl...

    Imaging, but not imaging
    We multicasted to 43 machines. Updated the image on the master. Multicasted the updated image to 36 machines. (the other 7 wouldn't join the session for some unknown reason). I visually verified that all 36 were imaging. One of the 8 which didn't rename appears to not even have been imaged. The problems with the previous image were still there. It's as though the machine didn't image even though I saw it take part in the session and the temp bar going across the screen. What the heck's going on here? AlaN As a try, what happens if you boot either to PXE ...

    Gridview I need to show an image on mouseover
    Please help.......I need to show an image on mouseover the rows in a gridview. See  http://tkcarsites.com/list_inv_vi.html  but the image has to be on the left hand side only.  see http://powerintech.com/dev/listview1.jpg  The image URL is also a column in the gridview      Any suggestions will be much appreciated.  Hi smatpit , You need to add onMouseOver and onMouseOut event to each cell of the GridView. Please take a look at following link on how to show different images to the left of the links when the mouse pointer moves over them: ...

    Image in image
    Hi, I have a project where clients viewing my website can buy t-shirts. They can choose from a number of t-shirt colors and shapes which are their plain colour. They can also choose a number of prints to be placed on the t-shirt. These will be graphics stored in a database. My problem is on how I can displaty the t-shirt with the graphics or logo they chose on te t-shirt. It would be something like drawing text on an image but instead drawing an existing image on the base image. Any Ideas? (I am using visual studio 2005 and vb.NET)   RegardsMerovingian you 1. You can create a...

    display different images(for image button) in template column for each row
    Hi i have a datagrid with a template column(dynamically created) with imagebutton in it. can anyone tell me how to display different images in this column for each row i could display the same image for the entire column thanks red This depends on the logic for selecting different images. If your image depends on the datasource of the DataGrid Item, then you need to set the image in the databound event of the column. Otherwise ... well, there might be many ways. What criteria do you want to use to select the data. Also, post here code used to define the temlate column (i gu...

    image and image
    // create an image object, using the filename we just retrieved System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath(file)); // create the actual thumbnail imageSystem.Drawing.Image thumbnailImage = image.GetThumbnailImage(64, 64, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);   now my question is how to display this image in my image1 control in asp.net (version 1.1) the below line of code is not working.  Image1.ImageUrl=thumbnailImage.ToString();Mark As Answer If my reply helped you. Hi, you can save t...

    Image on Image
    I am trying to display a page that has image of a map on it. The user can then place other images of red thumbtacks on the image at different locations. Then when these thumb tacks are clicked on, they open a folder of pics related to the area. I saw a method in the imageButton class that returns the (x,y) of the location where the user clicked. I thought I could use this information to place another, smaller image button, on that area. My problem is that i can't seem to get the bottom imageButton to be transparent so I can see the smaller one. Am i on the right track with this. Any advice would be appricated. You can contact me at adamgleiss@gmail.com. Thanks....

    Web UI with a large image holder, the image can be viewed by scrollbar!!
     Hi All,I have made a Web UI with a large image holder, the image is kept in a panel and the part which is not visible can be viewed by the panel horizontal scrollbar. Now the problem is I want a vertical line (marker) which indicates the position where the user has last viewed the image. This vertical bar position on the image helps in drawing the next page. This is similar to layering of images, which I don't know if is possible in Web. Any idea how to acheive this..  Regards,Lalit. ...

    Can you display data from a single row in multiple rows using a GridView?
    I am currently displaying 3 fields in a gridview and it looks something like this:First Name Last Name Age ======== ======== === Chris Messineo 40 John Smith 35 Tim Jones 30I need to modify the gridview and display a bio, but I want it to display on 1 full line below each line, like this:First Name Last Name Age ======== ======== === Chris Messineo 40 Chris was born in a log cabin... John Smith 35 At the age of 10 John invented... Tim Jones 30 Mr. Jones was always a curio...

    load an image and table row
     I want to upload an image to a table cell and also insert a new row on a asp.net table from code behindq1)I know how to upload an image but how do I display it as well in a table control?q2)how do i insert  a new row in  table from the code behind?  Define the table in .aspx file as below <asp:Table ID="tblImage" runat="server" BorderWidth="1px">In the code behind access that table and add the image to cell as shown below         TableCell tc = new TableCell();     &nbs...

    Web resources about - ADO.net problem: i can not view image data for the rest of my table rows except the image for the first row but i can read all the other non image fields for all rows. - asp.net.object-datasource

    Resources last updated: 3/4/2016 8:32:48 AM