Call a Method

  • Thread starter Thread starter Mariame
  • Start date Start date
M

Mariame

Hi Everyone
i have a web page that i write in it the connection string of the database &
i declare the session [Index Page]
i want when the user open any page & doesent start with the index page , i
dont have to redirect him to this page.
but i want to call a method where i declare the connection & the session
How Can I Do It?
Thx in Adv.
 
I mean that i want to put the connection string of the database in a method
that i can call anyware in the program, coz if i put the declaration in a
page , i have to redirect to this page in case of the connection string was
empty so the user couldnt put any page on the favorites coz everytime he
will have to start from the index page
How Can I do It?

Lars Netzel said:
You need to exaplin a little bit better cause I didn't get what you mean!

/lars

Mariame said:
Hi Everyone
i have a web page that i write in it the connection string of the
database & i declare the session [Index Page]
i want when the user open any page & doesent start with the index page ,
i dont have to redirect him to this page.
but i want to call a method where i declare the connection & the session
How Can I Do It?
Thx in Adv.
 
Well, create a separate class file and use this class to do any database
operations. This way, you declare and initialize your database connection in
one place
--
Kumar Reddi
http://kumarreddi.blogspot.com

Mariame said:
I mean that i want to put the connection string of the database in a method
that i can call anyware in the program, coz if i put the declaration in a
page , i have to redirect to this page in case of the connection string was
empty so the user couldnt put any page on the favorites coz everytime he
will have to start from the index page
How Can I do It?

Lars Netzel said:
You need to exaplin a little bit better cause I didn't get what you mean!

/lars

Mariame said:
Hi Everyone
i have a web page that i write in it the connection string of the
database & i declare the session [Index Page]
i want when the user open any page & doesent start with the index page ,
i dont have to redirect him to this page.
but i want to call a method where i declare the connection & the session
How Can I Do It?
Thx in Adv.
 
I see. You are storing the connection string in a Session variable? Unless
you have a good reason to do so (such as the connection string varies from
client to client), this isn't the best way to accomplish this.

Instead, store the connection string in the Web.config. For example, in your
web.config, add this after the <configuration> element:

<appSettings>
<add key="connString" value="Data Source=localhost;Integrated
Security=SSPI; database=YourDataBase" />
</appSettings>

To access it from any page within your project, use this:

ConfigurationSettings.AppSettings("connString")

That's a much better way of storing a connection string (or any other string
for that matter) across all pages in the application.

Happy coding,
Johann MacDonagh

Mariame said:
I mean that i want to put the connection string of the database in a method
that i can call anyware in the program, coz if i put the declaration in a
page , i have to redirect to this page in case of the connection string was
empty so the user couldnt put any page on the favorites coz everytime he
will have to start from the index page
How Can I do It?

Lars Netzel said:
You need to exaplin a little bit better cause I didn't get what you mean!

/lars

Mariame said:
Hi Everyone
i have a web page that i write in it the connection string of the
database & i declare the session [Index Page]
i want when the user open any page & doesent start with the index page ,
i dont have to redirect him to this page.
but i want to call a method where i declare the connection & the session
How Can I Do It?
Thx in Adv.
 
Back
Top