0

Hi Experts, I have visited the forum regarding this solution ,but could not get proper help. I got error :
Object reference not set to an instance of an object.

Line 18: <%
Line 19: 
Line 20: 	string proj_id=Session.Contents["proj_id"].ToString(); <-------- > pointing to this part
Line 21: 	OleDbConnection conn=new OleDbConnection(System.Configuration.ConfigurationManager.AppSettings["MM_CONNECTION_STRING_ictmdb"]);
Line 22: 	conn.Open();

Looking for expert openion and help

3
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by dnanetwork
0

hello naveedqadri!
because it's simply you do not have Session["proj_id"] ,so it don't exist at all.
you can try this:

protected void Page_Load(object sender, EventArgs e)
    {
        String s = Session.Contents["proj_id"].ToString();
        Response.Write(s);
    }

so you have the same error.
then try:

protected void Page_Load(object sender, EventArgs e)
    {   
        Session["proj_id"] = "test";
        String s = Session.Contents["proj_id"].ToString();
        Response.Write(s);
    }

so it works perfectly.
Regards!

0

Thanks Cocoll for helping me, one thing i don't know, same code is working well with my Oracle database, but i use it with mysql database it gives this error. Can you explain it , may be some problem with my data fetching etc ?
Thnaks again Cocoll.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.