Avoid IndexOutOfRangeException Indexing DataReader Columns?
Feb 9, 2010
I am having a little trouble with an 'IndexOutOfRangeException'. I think it is because when the code tries to get the DateModified col from the database it sometimes contains NULLS (the users haven't always updated the page since they created it).
Here is my code;
s = ("select datemodified, maintainedby, email, hitcount from updates where id = @footid")
Dim x As New SqlCommand(s, c)
x.Parameters.Add("@footid", SqlDbType.Int)
x.Parameters("@footid").Value = footid
c.Open()
Dim r As SqlDataReader = x.ExecuteReader
While r.Read
If r.HasRows Then
datemodified = (r("DateModified"))
maintainedby = (r("maintainedby"))
= (r("email"))
hitcount = (r("hitcount"))
End If
End While
c.Close()
I thought (after a bit of msdn) that adding;
If r.HasRows Then
End If
after adding I am still getting the same old IndexOutOfRangeException
(ps, I have tried datemodified as string / datetime)
View 4 Replies
Similar Messages:
Jul 21, 2010
i am getting this error "There is already open Datareader associated with this command which muct be closed first"
what are the chances of getting this error becoz it giving me so much problem
and how can i solve this error by writing a well code
View 3 Replies
Mar 17, 2011
I have a gridview with predefined columns and a selectcommand. Why do I get the columns twice? I want to keep the predefined columns and the selectcommand, but avoid getting the columns double.
<asp:GridView ID="gvMeldingen" runat="server"
AllowSorting="True" DataSourceID="MyDataSource"
onselectedindexchanged="GridView_SelectedIndexChanged"[code].....
View 1 Replies
Jan 25, 2010
I know about the benefits that full text indexing provides when indexing columns that contain LOB such as varbinary(max), varchar(max) etc. But is there an overhead involved when using full-text indexing and full text search on columns that contain a small amount of data, such as varchar(50)?
View 3 Replies
Aug 6, 2010
I have a condition to check weekdays with a particular time corresponding
to that day that were added to a grid view using a drop down list and two text boxes.
The drop down list has weekdays and textboxes has from and to time.
I have to verify a condition to avoid duplication of same day with same time should not occur in the table twice.
(i have used time picker jquery to get time.)
how should i write the condition in sql and use that in C#
View 5 Replies
Nov 15, 2010
I'm having a method that exports content from the database to excel files. The method taks as paramaters a DataReader param and a int param - the number of rows. For the number of rows i'm using a dataset, wich i fill using the same query as for the datareader. So I'm executing it twice... Is there a way I can avoid that? get the number of rows from the datareader?
View 1 Replies
Jul 28, 2010
I am getting an error that an open DataReader associated with this Command, when I'm not using datareader(though probably executereader() is the same thing) how would I close this if I don't have a datareader present?
using (SqlConnection conn = new SqlConnection(ConnectionString))
{
SqlCommand cmd = new SqlCommand("spSelectAllTypes",conn);
cmd.CommandType = CommandType.StoredProcedure;
[code]...
I just want to be able to databind a bunch of dropdownlist in one open connection. (before I had multiple open and closes for each control)
View 2 Replies
Oct 12, 2010
I am getting 'indexOutofRangeException occurred' error - 'FixedActual'
SqlDataReader dataReader = null;
SqlCommand Scmd = new SqlCommand("SalesGetRecalcOrderItemCosts", this._connection);
Scmd.CommandType = System.Data.CommandType.StoredProcedure;
[code]...
View 1 Replies
Jan 27, 2010
Can anyone tell me why I get this error:
I'm trying to output my query results:
SELECT * FROM sites LEFT JOIN pages ON sites.siteid=pages.siteid LEFT JOIN subpages ON Pages.pageid=subpages.pageid WHERE sites.siteID = 1 ORDER BY sites.siteid ASC
using the code:
[code]....
Source Error:
[Code]....
Line 35: Line 36: While reader.Read()Line 37: mydata &= reader.Item("sitename") & " " & reader.Item("pageid") & " " & reader.Item("pagetitle") & "<br>" & reader.Item("subpages.pageid")Line 38: Line 39:
View 14 Replies
Oct 19, 2010
I'm trying to get data from a CSV file and add it directly into a database using Linq.
I'm using the following code:
[Code]....
The code works if I remove all the but the first property e.g.
[Code]....
But then I get the old "System.IndexOutOfRangeException: Index was outside the bounds of the array." exception when adding more columns.
View 1 Replies
Jan 19, 2011
I am getting this error"System.IndexOutOfRangeException: There is no row at position 0." same code and concept working fine in 2 websites i could not able to solve this,only difference between current implementation and earlier implementation database,previously i used MySql database and now Ms-Excel data.I debugged data set is retreiving Code
Protected Sub chkSelect_CheckedChanged(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim indx As Integer
Dim strExcelConn As String =
[code...]
View 3 Replies
Dec 15, 2010
I have the following web service:
[ScriptService]
public class Handler : WebService {
[WebMethod]
public void method1() {
string json = "{ "success": true }";
System.Web.HttpContext.Current.Response.Write(json);
[code]...
The first method accepts a traditional html form post and response writes a JSON string to the page.The second method accepts a JSON value posted via AJAX and returns a serialized object.Both these methods work fine on their own but when put together in the same web service I get this error when calling method1:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
When I remove the arguments from method2 they work.Can anyone suggest why this is happening?
Edit:The problem spans from the argument type of method2. If I change it to a string or simple data type it works fine.As Joel suggests it's probably because Dictionaries can't be serialized.This doesn't seem to affect my requests sent by ajax and only breaks direct form posts to this handler.Therefore my workaround is to put the form post handlers in a separate file by themselves.Not ideal but works for my application.
View 1 Replies
Jan 27, 2010
I've got a FormView bound to an ObjectDataSource. The FormView/ODS selects and displays my data correctly but when I change the data and try to update,nothing (seemingly) happens.Stepping through the code and digging deeper into the stack trace and output window,I figured out that the following sequence of events happens:
- The ObjectDataSource drills down to System.Web.UI.WebControls.ObjectDataSourceView.BuildDataObject to create the object I specified in the "DataObjectTypeName" property
[code]...
- Here is where the IndexOutOfRangeException happens. Sometimes one or two of the data object's properties will be set, sometimes none. Either way, the exception is thrown and the sequence is stopped (the business object's update is never called).
- The exception is not thrown inside any of the properties' set methods.I'm assuming that the exception is happening when BuildDataObject is using Reflection to find my data object's properties (GetProperty() etc.. ). Since I can't see the source code of BuildDataObject and the debugger won't give me any more information, there is no way for me to see which property (if any) is causing this.I double checked the names and types of all 27 of the data object's properties.
View 1 Replies
Nov 30, 2010
I'm trying to do a master-detail by first search the database when a user click on the search button. Then display the result to a ListView control. After that, if the user click on the hyperlink, it displays the detail on the Formview control. Below are my code:
[Code]....
And here's the part that causes the error:
[Code]....
The error is on this line: string strID = ltvLusHmoob.DataKeyNames[e.Item.DataItemIndex].ToString();
View 9 Replies
Feb 23, 2011
I want to check that a specific url is indexed in google using asp.net.Is google provide any api, webmethod anything regarding this.
View 2 Replies
Jun 20, 2010
I have implemented URL rewriting and I would like someone to answer if my new URLs will be indexed by google or not.
BACKGROUND:
I have many databound linkbutton which redirects to URL like: www.example.com/product.aspx?PLU=4985783028
What I intended to do is to make above URL look like www.example.com/MY-Nice-Product1-For-Sale-4985783028.xyz . Whuich internally should rewritten as above. I could have easily implemented such URL rewriting but all my databound link button redirects to
/product.aspx?PLU=4985783028 and when this the page at this URL is served to browser it will look like
/product.aspx?PLU=4985783028 and not /MY-Nice-Product1-For-Sale-4985783028.xyz
WHAT I DID:So I implemented my own method of Rewrite. Steps for which I did is as follows
1. I wrote code inside Global.asax in Application_BeginRequest event.
2. I checked for URL if its product.aspx or not (using fullOrigionalpath.Contains)
3. If its product.aspx I would takeout the "PLU" Query parameter and by string manipulation and then call a function to determine product name from the unique ID ("PLU").
4. And then I would redirect the page to "/productname-PLU.xyz" (e.g. here productname is
"MY-Nice-Product1-For-Sale" . AND PLU is "4985783028" so that is redirects to "/MY-Nice-Product1-For-Sale-4985783028.xyz")
5. Once redirected, again, "Application_BeginRequest" event will be called. and there I would check if URL contains. ".xyz" extension.
6. If so, I would takeout PLU by string manipulation and then rewrite URL to right URL which looks like
"/product.aspx?PLU=4985783028"
7. Then after user will see "/MY-Nice-Product1-For-Sale-4985783028.xyz"
on their browser addressbar
This is how I achieved my goal so that all old URL redirects works too and all new URL works too and in both case user will see new URL.
Following is the code
[Code]....
So finally the question is "Will my new URL be indexed by Gooogle?" because the basic intention of doing this was to help with SEO .
View 10 Replies
Jan 18, 2014
I have perform indexing on date column in many of my sql tables. My question while applying indexing date we have sort option as well to perform the indexing in descending or ascending order.
While index the date column sort should be asc or desc.
If I sort desc will it increase performance because 98 percent time user is retrieving current data.
View 1 Replies
Mar 23, 2011
Is there a way to prevent search engines from indexing a site by modifying the ASP.NET Web.config file?
View 2 Replies
Apr 27, 2010
Developing a web site in .Net 4. Very close to being complete with most functionality, so I thought I would attack what seemed to be a tough one (something I have not done): site content search.
I've been digging around for an hour or so, and I'm a little perplexed. How do I perform content search on an ASP.net website?
A few things I'll throw out there before you answer with something I've already seen and cannot implement:
I am developing on a Win7x64 computer using VS2010 w/TFS.Site has been converted to .net 4, and is in C#.Will not have access to put site on Windows Server 2008 for another month, but would really like to implement search if at all possible beforehand.All that said, can I implement searching via indexing? I've looked at using Windows Search, but nothing looked like it worked right. This site will be served up on a Windows Web Server 2008. Do I need to somehow develop against a Server 2008 to implement search via indexing?
View 3 Replies
Jul 22, 2010
my webpage perform content search using Windows Indexing Servicemy production machine is Windows XP everything finethen i tested my published Website in Windoes 7the Summary Fields always empty
View 1 Replies
Aug 3, 2010
i am making relation between two datatables and m getting this error
in this ds.Tables(0).Columns("In_ID") datatype is string
ds.Tables(1).Columns("row_id") datatype is integer
how i do the type casting here to make dataset relation
ds.Relations.Add("Rel_1", ds.Tables(0).Columns("In_ID"), ds.Tables(1).Columns("row_id"), True)
View 3 Replies
Mar 31, 2010
what type of files can we search using Microsoft Indexing Service
View 3 Replies
Jun 13, 2010
i have made fulltext index in 4 columns in a table ( 2 ARABIC columns (title,Desc(html) AND ENGLISH(title,Desc(html))it works fine locally when i use contains function in search but in sever arabic search doesnt work well .
View 2 Replies
May 14, 2010
Situation:I have an ASP .NET application that will search through docs using Lucene. I want to run the initial indexing (the index will be incremental after the initial run so there wont be need to index the whole directory again in future). Currently, I have about 5GB of docs (45000files).Problem: My application times out before completing the process. I have altered the TimeOut like this:HttpContext.Current.Server.ScriptTimeout = 200000;but it still does not complete the process.
View 1 Replies
Jan 27, 2010
I would like to use the indexing service for search engine of the website. My problem is it can't search any Non-english words, it always return the message "The query contained only ignored words". Unbelievablely, differ result found in differ environments, in my local develop environment (Win XP (Chinese version)) is can search for any words, even non-english keywords. Another environment is server 2003 (English version), which is not work!
So I think it should be environment setting issue rather than .net setting or web.config or any other about the page encode, but i have no idea for how to setup the environment to fix this issue.By the way, my web.config have this setting, which is my googling result =.=
[Code]....
View 4 Replies