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 25: public void connection()
Line 26: {
Line 27: con.ConnectionString = ConfigurationManager.ConnectionStrings["matriConnection"].ConnectionString;
Line 28: con.Open();
Line 29: }
Source File: d:\matri1\App_Code\matrimonyclass.cs Line: 27
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
matrimonyclass.connection() in d:\matri1\App_Code\matrimonyclass.cs:27
admin_Default.Page_Load(Object sender, EventArgs e) in d:\matri1\admin\Default.aspx.cs:19
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) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927
classfile
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
/// <summary>
/// Summary description for matrimonyclass
/// </summary>
public class matrimonyclass
{
public SqlConnection con = new SqlConnection();
public SqlCommand cmd;
public SqlDataReader dr;
public SqlDataAdapter da;
public DataSet ds;
public string query;
public void connection()
{
con.ConnectionString = ConfigurationManager.ConnectionStrings["matriConnection"].ConnectionString;
con.Open();
}
public void ExecuteQuery(string query)
{
cmd = new SqlCommand(query,con);
cmd.ExecuteNonQuery();
}
public void ExecuteRead(string query)
{
cmd = new SqlCommand(query,con);
dr = cmd.ExecuteReader();
}
public void Getdataset(string quey)
{
cmd = new SqlCommand(query,con);
da = new SqlDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds);
}
public matrimonyclass()
{
//
// TODO: Add constructor logic here
//
}
}
This post has been edited by modi123_1: 31 July 2012 - 08:02 AM
Reason for edit:: highlight the lines THEN click the code tags button in the 'format text' box of the post.

New Topic/Question
Reply



MultiQuote







|