Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / May 2005

Tip: Looking for answers? Try searching our database.

I have written the code below:

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jensen bredal - 11 May 2005 10:35 GMT
public class Global : System.Web.HttpApplication

{

....

.....

.....

public static Thread t;

{

get { return post; }

}

public Global()

{

InitializeComponent();

}

public static String GetConnectionString

{

get { return ConfigurationSettings.AppSettings["DBConnStr"]; }

}

protected void Application_Start(Object sender, EventArgs e)

{

DataSet
ds=SqlHelper.ExecuteDataset(Global.GetConnectionString,CommandType.Text,"select
* from  table");

HttpContext.Current.Cache.Insert("data",ds.Table[0],null,Cache.NoAbsoluteExpiration,System.TimeSpan.FromHours(2));

t = new Thread(new ThreadStart(ThreadProc));

t.Start();

Thread.Sleep(3600);

}

....

.....

......

public void ThreadProc()

{

try

{

DataSet
ds=SqlHelper.ExecuteDataset(Global.GetConnectionString,CommandType.Text,"select
* from Table");

HttpContext.Current.Cache.Insert("data",ds.Tables[0],null,Cache.NoAbsoluteExpiration,System.TimeSpan.FromHours(2));

}

catch(Exception ex)

{

string str = ex.Message; // get the exeption as a string

}

...

.....

....

I want to create a thread that load the content of a database table into the
application cache.

But!!!

This cause the exception: "object reference not set to an instance of
anobject"

Can any someone tell me what i'm doing wrong?

Many thanks in advance

JB
Chad Z. Hower aka Kudzu - 11 May 2005 13:14 GMT
> This cause the exception: "object reference not set to an instance of
> anobject"

Why not debug it and find out what line its occuring on first?

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
     "Programming is an art form that fights back"

Blog: http://blogs.atozed.com/kudzu
jensen bredal - 11 May 2005 13:48 GMT
well the excepton occurs in "public void ThreadProc()"

on
Chad Z. Hower aka Kudzu - 11 May 2005 17:00 GMT
> well the excepton occurs in "public void ThreadProc()"

You need to narrow it down further. DEBUG it. Put a break point on the first
line. Now step thorugh and find out what line trips it. Then do it again, and
set watches till you find out what object is null.

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
     "Programming is an art form that fights back"

Blog: http://blogs.atozed.com/kudzu

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.