Database object works first time but fails after save
Hi I have a strange problem.
Got a simple db connection which works fine I can refresh the browser multiple times , all works fine. however if I go back to the view make no changes but just save it and then try to refresh the browser I get 'Object reference not set to an instance of an object.' I have to recycle the application pool on IIS to get it working again.
I'm using Umbracbo 7.5.2
the View code is:
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@using Umbraco.Core.Persistence;
@{
var db = new Database("ordersDb");
foreach (var a in db.Query<orders>("SELECT * FROM orders"))
{
<p> @a.id </p>
}
}
@functions
{
private class orders
{
public int id { get; set; }
}
}
The Error I get is:
Server Error in '/' 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 5:
Line 6: var db = new Database("ordersDb");
Line 7: foreach (var a in db.Query<orders>("SELECT * FROM orders"))
Line 8: {
Line 9: <p> @a.id </p>
Source File: d:\Sites\test.co.uk\public_html\Views\MacroPartials\test2.cshtml Line: 7
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
Umbraco.Core.Persistence.<Query>d__7`1.MoveNext() +462
ASP._Page_Views_MacroPartials_test2_cshtml.Execute() in d:\Sites....
Database object works first time but fails after save
Hi I have a strange problem. Got a simple db connection which works fine I can refresh the browser multiple times , all works fine. however if I go back to the view make no changes but just save it and then try to refresh the browser I get 'Object reference not set to an instance of an object.' I have to recycle the application pool on IIS to get it working again.
I'm using Umbracbo 7.5.2
the View code is:
The Error I get is:
Pull my hair out! any help would be very grateful
Anyone ???
is working on a reply...