hi frnds,
i have a certain application in vs2008 with several windows forms.my question is that i have to mention connectionstring on each n every form as:

con.ConnectionString = "Data Source=mypc;Initial Catalog=Main;User ID=me;Password=pwd"

Is there any way to define connectionstring for once for all forms and and one more thing if the database location is changed ,my application itself look for it wherever the database file is?

Recommended Answers

Define a global constant (or variable) in a module and set the value to your string. Then when you set con.connectionstring, set it equal to your global constant (or variable).

Jump to Post

All 4 Replies

Define a global constant (or variable) in a module and set the value to your string. Then when you set con.connectionstring, set it equal to your global constant (or variable).

will u please provide me the appropriate code as i m new to vb.net

The "Help" system is a great place to start for simple stuff. I suggest you look there before posting questions here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.