By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,205 Members | 1,066 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,205 IT Pros & Developers. It's quick & easy.

Call a Method

P: n/a
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.
Nov 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
You need to exaplin a little bit better cause I didn't get what you mean!

/lars

"Mariame" <ma************@hotmail.com> skrev i meddelandet
news:Ov**************@TK2MSFTNGP12.phx.gbl...
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.

Nov 19 '05 #2

P: n/a
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" <tr*****@apa.se> wrote in message
news:uM**************@tk2msftngp13.phx.gbl...
You need to exaplin a little bit better cause I didn't get what you mean!

/lars

"Mariame" <ma************@hotmail.com> skrev i meddelandet
news:Ov**************@TK2MSFTNGP12.phx.gbl...
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.


Nov 19 '05 #3

P: n/a
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" <ma************@hotmail.com> wrote in message
news:O4**************@TK2MSFTNGP14.phx.gbl...
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" <tr*****@apa.se> wrote in message
news:uM**************@tk2msftngp13.phx.gbl...
You need to exaplin a little bit better cause I didn't get what you mean!

/lars

"Mariame" <ma************@hotmail.com> skrev i meddelandet
news:Ov**************@TK2MSFTNGP12.phx.gbl...
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.



Nov 19 '05 #4

P: n/a
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" <ma************@hotmail.com> wrote in message
news:O4**************@TK2MSFTNGP14.phx.gbl...
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" <tr*****@apa.se> wrote in message
news:uM**************@tk2msftngp13.phx.gbl...
You need to exaplin a little bit better cause I didn't get what you mean!

/lars

"Mariame" <ma************@hotmail.com> skrev i meddelandet
news:Ov**************@TK2MSFTNGP12.phx.gbl...
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.



Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.