Answered by:
Index Out of range error

Question
-
User1274852898 posted
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { object nid = Request.QueryString[0]; object id = Request.QueryString[1]; object txt = Request.QueryString[2]; try { OleDbCommand comm = new OleDbCommand(); OleDbConnection conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source="****"); conn.Open(); comm = new OleDbCommand("UPDATE Notes SET [Note] = ?, [User] = ?, [Date Modified] = ? WHERE (ID = ?) AND ([Note ID] = ?)", conn); comm.Parameters.AddWithValue("[Note]", txt+" "); comm.Parameters.AddWithValue("[User]", User.Identity.Name); comm.Parameters.AddWithValue("[Date Modified]", DateTime.Now.ToString("dd/M/yyyy hh:mm:ss")); comm.Parameters.AddWithValue("[ID]", id); comm.Parameters.AddWithValue("[Note ID]", nid); comm.ExecuteNonQuery(); conn.Close(); } catch (OleDbException ex) { Response.Write(ex.Message); } Response.RedirectPermanent("~/Viewer Reports/ViewContactDetails.aspx?ID=" + Request.QueryString[1]); } }
ERROR:Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: indexDescription: 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: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
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: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index] System.Collections.ArrayList.get_Item(Int32 index) +9373696 System.Collections.Specialized.NameValueCollection.Get(Int32 index) +16 Contact_Management_UpdateNote.Page_Load(Object sender, EventArgs e) +89 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35 System.Web.UI.Control.OnLoad(EventArgs e) +91 System.Web.UI.Control.LoadRecursive() +74 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
plz explain the error ... this page is redirecting on a button click
object nid = Request.QueryString[0];object id = Request.QueryString[1];Response.RedirectPermanent("~/Contact Management/UpdateNote.aspx?NID=" + nid + "&ID=" + id + "&txt=" + TextBox1.Text.Trim());object nid = Request.QueryString[0];
object id = Request.QueryString[1];
Response.RedirectPermanent("~/Contact Management/UpdateNote.aspx?NID=" + nid + "&ID=" + id + "&txt=" + TextBox1.Text.Trim());
Wednesday, September 22, 2010 9:31 AM
Answers
-
User1274852898 posted
thnx every1 .. i just resolved the error
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, September 22, 2010 10:09 AM
All replies
-
User77042963 posted
Your page url should include three querystrings and looks like this format:
....yourpage.aspx?p1=a&p2=b&p3=c
Wednesday, September 22, 2010 9:39 AM -
User888410735 posted
Hi,
Do check the query String that you are passing.
Wednesday, September 22, 2010 9:41 AM -
User1274852898 posted
Response.RedirectPermanent("~/Contact Management/UpdateNote.aspx?NID=" + nid + "&ID=" + id + "&txt=" + TextBox1.Text.Trim());
this is my querystring.
Wednesday, September 22, 2010 9:47 AM -
User1274852898 posted
thnx every1 .. i just resolved the error
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, September 22, 2010 10:09 AM