2 Replies - 1319 Views - Last Post: 31 July 2012 - 02:58 PM Rate Topic: -----

#1 manusn  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 31-July 12

iam create a matrimony site

Posted 31 July 2012 - 08:01 AM

Server Error in '/matri1' 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 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.


Is This A Good Question/Topic? 0
  • +

Replies To: iam create a matrimony site

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9218
  • View blog
  • Posts: 34,621
  • Joined: 12-June 08

Re: iam create a matrimony site

Posted 31 July 2012 - 08:02 AM

Question; is there one?
Was This Post Helpful? 0
  • +
  • -

#3 Nakor  Icon User is offline

  • Professional Lurker
  • member icon

Reputation: 444
  • View blog
  • Posts: 1,492
  • Joined: 28-April 09

Re: iam create a matrimony site

Posted 31 July 2012 - 02:58 PM

Does your web.config contain a connection string named "matriConnection"?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1