Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 global.asax file: APPLICATION VARIABLE

Author  Topic 

mary_itohan
Posting Yak Master

191 Posts

Posted - 2007-11-20 : 15:02:56
Hello,
whats wrong with the code below ?

Its meant to run in the global.asax file

I just want to make an object counter for all hits
Mary


[CODE]void Application_Start(object sender, EventArgs e)


{

Application("usercount") == 1 ;

}[/CODE]

Yes O !

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-11-20 : 15:25:55
== is the comparison operator, not the assignment operator. You need to use = to assign a value.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2007-11-20 : 15:27:00
More like this, change the brackets below


void Application_Start(object sender, EventArgs e) 


{

Application["usercount"] = 1 ;

}
Go to Top of Page

mary_itohan
Posting Yak Master

191 Posts

Posted - 2007-11-20 : 15:49:07
Ok,
thanks. However i have another error incrementing it


Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0019: Operator '+' cannot be applied to operands of type 'object' and 'int'

Source Error:



Line 31: protected void Button3_Click(object sender, EventArgs e)
Line 32: {
Line 33: Label2.Text = Application["usercount"] + 1 ;
Line 34: }
Line 35: }




Yes O !
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2007-11-20 : 16:55:34
Convert the Application object to integer with the convert function.
Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2007-11-21 : 00:41:33
I'd sugest going and buying a C# book. You are going to keep running into problems with the basics of the syntax until you expand some of your background knowledge.

Damian
"A foolish consistency is the hobgoblin of little minds." - Emerson
Go to Top of Page
   

- Advertisement -