Here is the error message

Object reference not set to an instance of an object.

Line 18: FuelDSTableAdapters.FuelTableAdapter dsFuelTableAdapter = new FuelDSTableAdapters.FuelTableAdapter();
Line 19: decimal totalFuel = (decimal)dsFuelTableAdapter.TotalFuel(DateTime.Parse(TextBox2.Text), DateTime.Parse(TextBox1.Text));

Weird thing is - it works based on the dates I put into the text boxes. I think it has something to do with when I moved the database from one pc to another...
If I do not query any data added to the database before I moved it to the new computer, it works. However, as soon as the dates I enter into the textboxes try to use new data - I get this error message.

I've deleted all the data - added some new data and now I get this error every time.

you get this error when your object does not contain anything except null.

and still you wanna use it

i think u r data is not captured by Adapter..

Debug..and use try catch...

I know what an object ref null exception is, but why would the object be null for only new data added to the database after I transferred the sql db to the new pc!!!?

I tested this some more and added the original db saved on the old computer - as long as I do not populate it with any new data it works fine. Also, I do not get this error on the old computer.

I've been debuggin this for the last 2 days - using a try catch won't show me anything new --- Anyone ever have this issue?

Any takers?

Upload your solution. I don't have any idea what could cause this off hand but there is a lot of designer generated code in datasets. You need to find out where exactly the null reference is... and to do that you need to step through the dataset. Pop in to the designer file and you'll notice these attributes:

[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]

This instructs the debugger to step through those lines. To turn that off go to "Tools -- Options -- Debugging -- General" then uncheck "Enable just my code (Managed Only)" then run the project. You should now step in to the dataset and see where its blowing up.

just make sure your function will return some value. another thing does your argument sequence is correct ? i mean suppose you have to pass first TextBox1.Text and then TextBox2.Text..

Also set Alt + Ctrl + E on your .vb or .cs file. Then check Thrown check box for "Common Language RunTime Exception" option. It will redirect you to the place from where the error is coming.

try it !!!


========================================================================================

I know what an object ref null exception is, but why would the object be null for only new data added to the database after I transferred the sql db to the new pc!!!?

I tested this some more and added the original db saved on the old computer - as long as I do not populate it with any new data it works fine. Also, I do not get this error on the old computer.

I've been debuggin this for the last 2 days - using a try catch won't show me anything new --- Anyone ever have this issue?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.