Adding Images In Loop (while Reader.read) Fails

Mar 27, 2011

I have following code that I can only add one image per row although I can add Listbox items as I wanted.

If "imgtag" 1~5 is checked, I get these in the listbox.

ie. ImageID = "cat"

listbox1. item gets - cat1, cat2, cat3, cat4, cat5

however I can only create the last image instead of 5 images.

- imageID - cat5

I assign each image unique ID.

If reader2.HasRows Then
While reader2.Read
Dim img1 = Convert.ToString(reader2("imgtag1"))
Dim img2 = Convert.ToString(reader2("imgtag2"))
Dim img3 = Convert.ToString(reader2("imgtag3"))
Dim img4 = Convert.ToString(reader2("imgtag4"))
Dim img5 = Convert.ToString(reader2("imgtag5"))
Dim blogimg = Convert.ToString(reader2("ImageID"))
Dim a As New HyperLink
a.Attributes.Add("onclick", "return hs.expand(this)")
a.Attributes.Add("href", "../../blog/images/" + blogimg)
Dim img As Image = New Image
img.ImageUrl = "~/blog/images/" + blogimg
img.Width = 200
If img1 = "1" Then
Dim blogimg1 As HtmlTableCell = CType(FindControl("blogimg1"), HtmlTableCell)
img.ID = blogimg + "1"
a.Controls.Add(img)
blogimg1.Controls.Add(a)
ListBox1.Items.Add(blogimg + "1")
End If
If img2 = "1" Then
Dim blogimg2 As HtmlTableCell = CType(FindControl("blogimg2"), HtmlTableCell)
img.ID = blogimg + "2"
a.Controls.Add(img)
blogimg2.Controls.Add(a)
ListBox1.Items.Add(blogimg + "2")
End If
If img3 = "1" Then
Dim blogimg3 As HtmlTableCell = CType(FindControl("blogimg3"), HtmlTableCell)
img.ID = blogimg + "3"
a.Controls.Add(img)
blogimg3.Controls.Add(a)
ListBox1.Items.Add(blogimg + "3")
End If
If img4 = "1" Then
Dim blogimg4 As HtmlTableCell = CType(FindControl("blogimg4"), HtmlTableCell)
img.ID = blogimg + "4"
a.Controls.Add(img)
blogimg4.Controls.Add(a)
ListBox1.Items.Add(blogimg + "4")
End If
If img5 = "1" Then
Dim blogimg5 As HtmlTableCell = CType(FindControl("blogimg5"), HtmlTableCell)
img.ID = blogimg + "5"
a.Controls.Add(img)
blogimg5.Controls.Add(a)
ListBox1.Items.Add(blogimg + "5")
End If
End While

View 2 Replies


Similar Messages:

ADO.NET :: Can't Get Reader.hasrows And Reader.read To Work Together In Code Behind

Feb 22, 2011

I have some code in my vb.net code behind that queries a database, and if there is data, outputs it from the codebehind to a datalist on my asp.net page. In addition to sending the data to the datalist on the page, I need to take the value from "mbillaty" that is returned from the sql query, and have that value be the selected value for a drop down box also on the page. I can get either the datalist to fill, or the selected value for the dropdown box to be selected depending upon which bit of code I place before the other (ARGH), but I can't get them to both work together on the page. What am I doing wrong?

[Code]....

View 2 Replies

How To Get From Loop Session On Data Reader

Nov 26, 2010

I am trying to send session on Loop and trying get .

[code]....

In above code, I just only get same SessionId on every news headings, how do I get next row session id?

View 2 Replies

DataSource Controls :: Loop Through Reader Using VB?

Jan 7, 2010

how I can loop through the results in VB, I only ever seem to get the last row, I would like to list all rows.

My code is below

[Code]....

View 3 Replies

DataSource Controls :: Finding Code To Loop Through The Reader And Output The Details On Individual Lines Of The Page

Jan 14, 2010

I'm currently trying to build a html table from the results of a sql data reader. As my table has multiple records, I want the code to loop through the reader and output the details on individual lines of the page. In ASP I have done this in the past using something like

[Code]....

but as I am using data readers I'm not sure what the equivalent is.

View 3 Replies

Web Forms :: Read Value From Barcode Reader Using C#

Jun 12, 2012

I have a barcode scanner . I want to read the barcode to a textbox in my asp.net application.

.So how can i get the barcode number into textbox.

View 1 Replies

DataSource Controls :: Can Update A Record In A Table That Has Been Read By Reader

Apr 10, 2010

I have been able to successfully read a row of data from an SQL table using two column parameters. Now I would like to update this row with new information. Is this possible since the reader does not specify which row was read with the 'reader.Read();' command?

View 7 Replies

SQL Server :: Invalid Attempt To Call Read When Reader Is Closed?

Jan 28, 2011

I have a function which allows me to quickly load SQL results into an SQLDataReader.

This is a very effective way for me to do this as it can be used for inserts, updates and selects very easily throughout my code.

However, I have noticed some potential memory issues with my site while using this (I keep having to do iisresets when working locally because all the pools are used up) so I am trying to use "Using" rather than "Dim" in an effort to ensure that the connection is always disposed.

I call the function in the following way:

Dim RS As SqlDataReader = SQL.Exec("sp_MyStoredProcedure " & ID)
If RS.Read Then
Return RS("Column_Name")
End If
RS.Close()

[Code].....

I now get the error "Invalid attempt to call Read when reader is closed" when calling the function on the line "If RS.Read Then".

View 24 Replies

Controls :: How To Read Programmatically Generated Barcodes Using Barcode Reader

May 25, 2013

I used the barcode example to my application and it generated barcode perfectly now I want to know that can this barcode image is readable by a barcode reader device ?

If Yes then how and if no then why and how to do ?

View 1 Replies

MySql.Data.MySqlClient.MySqlException: Invalid Attempt To Read When Reader Is Closed

Jan 15, 2010

so i have a content page that load some content into repeater one of the repeater items is UserControl, when the page is load for the first time everything is perfect, but if i try to do postback and reload the repeater i get this error:
Code:

Exception Details: MySql.Data.MySqlClient.MySqlException: Invalid attempt to Read when reader is closed.

this error is raised in the repeater databind event.

View 10 Replies

DataSource Controls :: Invalid Attempt To Call Read When Reader Is Closed ObjectDataSource?

Feb 16, 2010

Environment is : vwd2008, asp.net 3.5, linq to sql object model, formview, stored procedure used for query.On going problem... I have a simplified page with a webform content area from a master page. The content area contains a FormView connected to an object data source thru the design view tag. The O/R designer has the Lease Table and the stored procedure in the method area.

The stored procedure selects all records from a single table. I an using the DatabaseDataContext and selecting stored procedure name which has "return SingleResult".. There is no code written; the design view was used to create everything. The stored procedure executes in VWD 2008 express tab and shows desired records. I would like to use the O/R and Linq to SQL, and objectdatasource BUT.

View 1 Replies

ADO.NET :: Linq2Sql Error: "Invalid Attempt To Call Read When Reader Is Closed"

Aug 24, 2010

I've read up on this error from other posts and on other sites, but haven't found a solid resolution to the issue yet. My setup is as follows:

I have a RepositoryBase class that fields certain db calls that all repositories need to perform. In one such call, "GetSecurityGroup", it works most of the time, but will seemingly at random throw an exception with the error "Invalid attempt to call Read when reader is closed." All other Repository classes inherit from this one, and they all use the same DataContext object, which I understand isn't thread safe. Since there could be multiple calls to the DataContext object on the same page, perhaps one is using the DataContext when the next tries to do so. I'm not sure. What can I do to ensure this doesn't happen?

View 1 Replies

Web Forms :: Loop Through The Elements Of MyDataReader.Read()

Oct 28, 2010

cmd objects returns a set of sampleids. i want to loog through those ids as follows.

myDataReader = cmd.ExecuteReader();
ty{
While(Mydatareader.Read())
{
some logic.....
}
}
catch(exeception ex)
{
Console.Write("{0}", ex.Tostring());
System.Threading.Thread.Sleep(1000 * 60 * 2);
}

everthing is working fine. But when the exception rises the exception shown in command prompt.

What i need is .. when the exception rises .. i need to stop my execution for 2 minutes and then start the loop from the same element .. like using goto statment... but for loop it is working fine .. how to implemnt that logic for mydatareader.read().

View 5 Replies

Adding Linebreak In Loop?

Mar 10, 2011

I use the following code to add smoe fileupload controls on my page. I'd like a line break between each one, but am having trouble getting it to work.

For i As Integer = 1 To 2
Dim fileupload As FileUpload = New FileUpload
fileupload.ID = "FileUp" & i
placeUpload.Controls.Add(fileupload)
Next

View 1 Replies

Web Forms :: Adding A New Row To GridView Fails - Index Out Of Range?

Mar 15, 2011

I'm having a problem when trying to add a new row to a grid view when the grid view paging is "2" for example. Basically, when the data I'm trying to add will be on page number two of the grid, the drop down list I'm trying to bind raises an exception saying that the index is out of range.

How can I add a new grid row with paging and how to tell the drop down list that the row it is looking for is no longer 11, but 1 on the second page?

View 5 Replies

Adding A Work Item To TFS 2010 From .NET App Fails Due To Permissions?

Feb 16, 2011

I'm working on an ASP.NET webforms app that will serve as a simple intake form to create work items in TFS 2010.The app works correctly when I run it locally in debug mode--the submission completes and the work item is created.

When I publish the form to our dev server, it yellow screens and throws the following error:

[SecurityException: TF50309: The
following account does not have
sufficient permissions to complete the
operation: DOMAINNAMESERVERNAME$. The
following permissions are needed to
perform this operation: View
collection-level information.]

In my code, I'm attempting to access TFS using a service account, and from what I can tell the service account is being used correctly when I run in debug mode.Here's what my C# looks like:

string tfsServerUrl = "http://servername:8080/tfs";
string tfsProject = "Web Team Projects"; [code]....

If I set a breakpoint at the tfs.Authenticate() line, the server object shows the service account name as the current user and IsAuthenticated = true.

The line in the exception that mentions SERVERNAME$ is what's stumping me. It's seems like IIS is deciding to try to access TFS with the app pool identity instead of the credentials that I'm explicitly supplying.Our dev server is a Server 2008 box running IIS 7.

View 1 Replies

Forms Data Controls :: Loop Gridview Rows To Read One By One

Mar 24, 2011

How do I loop the gridview to read or insert one row by one row?I have a database which has a Primary key. Currently,all the rows seems to appear at one time.Even when I use a counter,it did read one row from a textbox(which is for my testing to read one row) but in the database,it still inserts the whole rows from the gridview.I can't click button twice as it will occur an error "Primary Constraint".

View 6 Replies

DataSource Controls :: How To Read Data Values Of A Table Using Loop In Sqlserver

Feb 10, 2010

I am using vs2008, Sqlserver2008.

my table: PostGL having data like thi

AutoIdx TxDate Id AccountLink Description Debit Credit
3 2010-01-22 JL 2 bcb 0 35.09
5 2010-01-28 JL 2 g 3.51 0

select AutoIdx,TxDate,Id,AccountLink,Description,Debit,Credit,(Debit-Credit) as Actual from PostGL where Id='JL' and AccountLink=2

AutoIdx TxDate Id AccountLink Description Debit Credit Actual
3 2010-01-22 JL 2 bcb 0 35.09 -35.09
5 2010-01-28 JL 2 g 3.51 0 3.51

I am trying in view like this

declare @cnt int
declare @i int
set @budget=20
set @cnt= (select COUNT(*) from PostGL where AccountLink=2 )
set @i=1
WHILE (@i<=@cnt )
BEGIN
set @tdebit=??

END

I am taking count the no of rows having AccountLink=2
I need to read all debit,credit and add all debit into totaldebit,all credit into totalcredit independently from table.
then i need to show the totaldiff as Actual.
i need ....totaldiff=totaldebit-totalcredit

View 3 Replies

Configuration :: Adding Values To A Config File With Foreach Loop From Sql Database?

Sep 2, 2010

I have added the below tag in my web.config file;

<RewriterConfig configSource="configuration
ewriter.config"/>

It gets the rewrite vlues from another config file. I need to update this rewriter.config file dynamically.

I need to gets values inside it from sql databse. here is the look of the file

<?xml version="1.0"?>

View 3 Replies

SQL Reporting :: PDF Rendering Fails With Reporting Service For Some JPG Images?

Jun 13, 2010

I am using Microsoft SQL server 2008 reporting service to generate PDF reports for my application.All was working fine, until I start to get the following error. I came to know after some google that this is because of some JPG images having metadata. If I have png image then its fine, but for me to convert these jpg to png is not an option, since all I have available is JPG.I installed service pack 1 as well, but its same. I have following SQL server installed.

"Microsoft
SQL Server 2008 (SP1) - 10.0.2531.0 (X64) Mar 29 2009 10:11:52 Copyright (c) 1988-2008 Microsoft Corporation Standard Edition (64-bit) on Windows NT 6.0 <X64> (Build 6002: Service Pack 2)"

I found few solutions like mentioned here http://support.microsoft.com/kb/967618 But thats for 2005. Surprisingly, already solved error for 2005 coming for 2008.

Non-negative number required.
Parameter name: value
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: Non-negative
number required.
Parameter name: value

Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: [ArgumentOutOfRangeException: Non-negative number required.
Parameter name: value]
System.IO.MemoryStream.set_Position(Int64 value) +10435528

View 3 Replies

Web Forms :: How To Tell C# To Read The Images From The APP_THEME Folder

Apr 12, 2010

I need to tell somehow to ASP.NET to read the images from the ASP.NET APP_THEME folder.

so instead of this:

[Code]....

View 3 Replies

JQuery :: Lightbox That Read Images From Database?

Nov 5, 2010

i want a lightbox for image that it load images from database.

View 1 Replies

Adding 'Watermark' To Images On The Fly?

Mar 28, 2011

How can i do that with ASP?

Is this process going to be a great overload for the server?

Could i use an image for a watermark instead of simple text?

View 4 Replies

Assemblies - Embed Js / Css Images Into Separate Assembly To Read From Website

Sep 3, 2010

I'd like to create a class library project where embed resources like js, css and maybe image files. I would compile it and copy the dll into the bin folder of my web site to include the resources into my pages with GetWebResourceUrl.

I tried with an assembly that have no .cs files, but it doesn't seem to work, I can't see the namespace of the assembly in the web project.

View 1 Replies

Forms Data Controls :: Retain Values In A FormView When Validations Fails Or The SQL Fails On An Insert?

Oct 6, 2010

To me this should be much easier, but I can't seem to retain the values that are put in the Insert template upon a validation failure or when the sql fails. This will prevent the user from having to retype everything agin in the event of a failure.

As you can see I am using the Sub Insert_Click and not using an insert through the wizard. so the fields are unbound textboxes on the form. There are 2 dropdowns that provide choices for the other fields.

I pasted in the code using the text only option becuase the format was getting messed up. I probably need more background on why the fields are blanking out.

[code]....

View 8 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved