global database connection

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I place an object OleDbConnection on my web form.
Then I can set up in properties the connectionstring.
If I make another form and I drop an OleDbConnection to it how can I use the
connectionstring from the previous form. I don't want to write code to do
so. Isn't that possible to be done only using the designer.

For exmample some grid objects could be bound to a file that contains the
connection string. Then I work only with the designer - no code written. Is
there a similar solution in asp.net
 
Most people put the connection string in the web.config file or even in the
registry and reference it from there.

You can add the connection string to the web.config like this:

<appSettings>

<add key="strConnection" value=""Driver={SQL
Server};Server=MySQLServerName;Database=MyDatabaseName;Uid=MyUsername;Pwd=MyPassword""/>

Then fetch it in your code like this:

strConnection= ConfigurationSettings.AppSettings("strConnection")
 
That is great though I don't want to write code to do so. Can't I do this in
the designer using the Dynamic Properties?
 
Back
Top