Link to home
Create AccountLog in
Avatar of MikeCombe
MikeCombeFlag for United States of America

asked on

How to set a session variable in a Sub or Function

Greetings,

The idea is that I can change the values in a database... and that the desktop application will check the database every 5 minutes and use the new values in the desktop application program.

So, I need to set a session variable, Session("timer1_interval") using a SUB or FUNCTION.
The sub/function will be triggered by another timer (timer_config) in the desktop application.

I want to run a timer (timer_config) every 5 minutes, where it contacts a database table,
reads the current values (timer1_interval = 60000) and then sets a new value into the session variable (Session("timer1_interval") = 60000).

Then, if I set the database value to 90000....5 minutes later the session variable will be updated and the new value will be  (timer1_interval = 90000)

How to set a session variable in a Sub or Function ?
Is there a better way to achieve this ?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of MikeCombe

ASKER

Here's what I am trying to do....

Visual Studio 2010, VB.net, desktop application
Form1.vb (code behind)

    Public Sub set_session_var()
        Dim someValue As String = "123"
        Session("myValue") = someValue
    End Sub


I get an error on the line: Session("myValue") = someValue

Error:
Session is not declared.
It may be inaccessible due to its protection level.
hi try the link below.
How To Use Session in Windows Application
hope this helps.
didn't really solve the problem. I found another way. thanks anyway.