Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   connections strings and declaring (http://www.go4expert.com/forums/connections-strings-declaring-t26060/)

allenkb 15Jun2011 01:11

connections strings and declaring
 
I am developing a porgram that access the database a fair amount as there are various froms that do differnt things. What i want to do is decalre the connections string once!! and use it through out my program so i can change it easily if i choose. Where would i decalre this and how would i use it later.?

Currently i have it decalred in every form and that isnt gogin to make changes easier dwont he road.

so what i have is the following many times throughout my program

Dim cn AsNew OleDbConnection
cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Z:\Documents\Visual Studio 2008\Projects\Dealer Mangement\Dealer Mangement\dealerman.accdb;Persist Security Info=True"
cn.open()

lines of code to do database stuff

cn.close()



i would think if i decalred things correctly all i ned is where or when i need to do something

cn.open()

lines of code to do database stuff

cn.close()


All times are GMT +5.5. The time now is 03:26.