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

Source Error:


Line 17: public partial class home : System.Web.UI.Page
Line 18: {
Line 19: SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString.ToString());
Line 20: protected void Page_Load(object sender, EventArgs e)
Line 21: {


Source File: e:\0\2\17\38\2669038\user\2930392\htdocs\home.aspx.cs Line: 19

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
home..ctor() in e:\0\2\17\38\2669038\user\2930392\htdocs\home.aspx.cs:19
ASP.home_aspx..ctor() in App_Web_home.aspx.cdcab7d2.zddxi6v4.0.cs:0
__ASP.FastObjectFactory_app_web_home_aspx_cdcab7d2_zddxi6v4.Create_ASP_home_aspx() in App_Web_home.aspx.cdcab7d2.zddxi6v4.2.cs:0
System.Web.Compilation.BuildResultCompiledType.CreateInstance() +32
System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +119
System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +33
System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +40
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +160
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +93
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155


pleaes help with a solution

Please debug and check what is your connection string value from Web.Config. Is it correct? Try to open the connection. See what is error message.

hii..

Check for your connection string path ..

And please mark it as solved if it helped you out.

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.