connections strings and declaring

Discussion in 'Visual Basic ( VB )' started by allenkb, Jun 14, 2011.

  1. allenkb

    allenkb New Member

    Jun 14, 2011
    Likes Received:
    Trophy Points:
    New Brunswick Canada
    Home Page:
    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 As New 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"

    lines of code to do database stuff


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

    lines of code to do database stuff


Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice