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

Recommended Answers

All 4 Replies

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!

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.

hello again.
you can post your code for helping you otherwise i can't.

dude check for null !

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.