connections strings and declaring

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

  1. allenkb

    allenkb New Member

    Joined:
    Jun 14, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Porgrammer
    Location:
    New Brunswick Canada
    Home Page:
    http://www.monquart.com
    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"
    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()
     

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