Sunday, February 19, 2012

Global connection string?

A sample connection string is something like this...

"Server=sql.company.com;Database=myDatabase;Trusted_Connection=True;"

My question is, since the actual .com must go into the string, if you change host companies,
you will have to go through all pages and also change the connection string.

I know there must be a way to declare the string once in like the global.asax and then
refer each page to that string.

I've been hunting around for a sample on how to do this.

Anyone know a good link to refer to?

Thanks,

ZathNever mind all, I forgot about putting it in a class... DOH...

Sorry to waste anyones time...

Zath|||Hi Zath,

There are obviously many ways of doing this. A method I make use of is to declare a connection string variable in global.asax and call it anywhere I need it within the current project.

The declaration is done this way:

Public Shared connString as String = "your parameters"

Calling this is done this way:

Global.connString

I hope this helps.

No comments:

Post a Comment