473,386 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

anything wrong with line 29?

Hi,

Server Error in '/WebSite1' Application.
Object reference not set to an instance of an object.
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.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 27: MyConnection.Open();
Line 28:
Line 29: MyCommand = new SqlCommand("select * from users where user_id='" + Request.QueryString["id"].ToString() + "'", MyConnection);
Line 30: MyAdapter = new SqlDataAdapter(MyCommand);
Line 31: MyDataSet = new DataSet();




Source File: c:\Documents and Settings\karen\My Documents\Visual Studio 2005\WebSites\WebSite1\Admin\UserEdit.aspx.cs Line: 29

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
Admin_UserEdit.Page_Load(Object sender, EventArgs e) in c:\Documents and Settings\karen\My Documents\Visual Studio 2005\WebSites\WebSite1\Admin\UserEdit.aspx.cs:29
System.Web.Util.CalliHelper.EventArgFunctionCaller (IntPtr fp, Object o, Object t, EventArgs e) +13
System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object sender, EventArgs e) +45
System.Web.UI.Control.OnLoad(EventArgs e) +80
System.Web.UI.Control.LoadRecursive() +49
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3745

Plz help. Tq

Karen
Mar 9 '08 #1
3 859

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 27: MyConnection.Open();
Line 28:
Line 29: MyCommand = new SqlCommand("select * from users where user_id='" + Request.QueryString["id"].ToString() + "'", MyConnection);
Line 30: MyAdapter = new SqlDataAdapter(MyCommand);
Line 31: MyDataSet = new DataSet();



Karen
Make sure that id exists in your query string i.e.
the url to this page should look some thing like this:
http://..../yourpage.aspx?id=someValue
Mar 9 '08 #2
saran23
28
Hi,

Server Error in '/WebSite1' Application.
Object reference not set to an instance of an object.
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.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 27: MyConnection.Open();
Line 28:
Line 29: MyCommand = new SqlCommand("select * from users where user_id='" + Request.QueryString["id"].ToString() + "'", MyConnection);
Line 30: MyAdapter = new SqlDataAdapter(MyCommand);
Line 31: MyDataSet = new DataSet();




Source File: c:\Documents and Settings\karen\My Documents\Visual Studio 2005\WebSites\WebSite1\Admin\UserEdit.aspx.cs Line: 29

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
Admin_UserEdit.Page_Load(Object sender, EventArgs e) in c:\Documents and Settings\karen\My Documents\Visual Studio 2005\WebSites\WebSite1\Admin\UserEdit.aspx.cs:29
System.Web.Util.CalliHelper.EventArgFunctionCaller (IntPtr fp, Object o, Object t, EventArgs e) +13
System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object sender, EventArgs e) +45
System.Web.UI.Control.OnLoad(EventArgs e) +80
System.Web.UI.Control.LoadRecursive() +49
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3745

Plz help. Tq

Karen



Hi, Null reference exception Will be raised when any object is null,
So Check for everything in the line of code, The connection string must be initialised correctly, the table name must be correct,
I think there is some problem with the quotation marks used to enclose the value, Check this, Set a breakpoint in the line and check for the values.

Thanks
Saravanan
Mar 10 '08 #3
Plater
7,872 Expert 4TB
I would bet money on it coming from:
Request.QueryString["id"].ToString()

You should be verifying that Request.QueryString["id"] actually exists before building a string with it.
Mar 10 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: greenflame | last post by:
I have been working for some time on a script that will show a matrix with the elements aligned on the right for sometime and finally got it to work. Then I did some patching up and ran the script...
2
by: olekristianvillabo | last post by:
The method cursor.executemany is there in order to avoid multiple calls to cursor.execute(). I have tried, with success, to do like every single example (that I have found on the www) on the...
2
by: Mano kumar | last post by:
hello guys, i'm having a very strange problem, this is a simple insert code. andthe insert stmt has NO problem cos i've tried it on my access table. and heres the error msg Operation must use...
138
by: Ian Boyd | last post by:
i've been thrown into a pit with DB2 and have to start writing things such as tables, indexes, stored procedures, triggers, etc. The online reference is only so helpful. The two pdf manuals are...
1
by: James | last post by:
this is a console program to convert ANSI to UTF8 format. Although in notepad i open the source file (which is ansi), and after running the program below, and re-open in notepad (it shows utf8...
17
by: so many sites so little time | last post by:
all right so the script is pretty simple it goes it retrives what the id of the post is and it lets you edit it well no it doesnt. now if you go to www.kirewire.com/pp2/index/php you will see a...
83
by: Anonymous | last post by:
Came across some code summarized as follows: char const* MyClass::errToText(int err) const { switch (err) { case 0: return "No error"; case 1: return "Not enough"; case 2: return "Too...
7
by: criveraf | last post by:
Hi there, I wasn't sure where to put this question, since it deals with both PHP and MySQL. I apologize if this is not the correct forum for this. I am working with a simple PHP application...
4
by: Spiros Bousbouras | last post by:
I got the following programme from an old post: http://tinyurl.com/53oa6o It was given at a job interview and the question was "The following program works, but what is a potential problem with...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.