Results 1 to 4 of 4

Thread: connection to database

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2007
    Posts
    24

    connection to database

    i use visual web developer n microsoft sql server for database,so my source code for connection to database


    Dim sqlConn As SqlConnection = New SqlConnection()

    sqlConn.ConnectionString = "Data Source=NORA;Initial Catalog=myAccount;User Id=sa;Password=password;"
    sqlConn.Open()

    my questions is:

    everytime i want access data from database, i need to write this source code,, so if have 10 page that need acces to database, i have to write the same source code, if i need to change the location of server, i need to modify the source code in all pages,

    so i hope anybody can give me solution where i do need to write repeatly the same code, my plan is want to write the source code for connection in some file or some place, and invoke or call them as many times as my application needs..
    please help me now

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: connection to database

    Store the connection string in your config file and have every connection retrieve it from there.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2007
    Posts
    24

    Re: connection to database

    how to retrieve it, can u write the code to retrieve it...

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jan 2007
    Posts
    24

    Re: connection to database

    how to retrieve it, can u write the code for me to retrieve it, example coding to do it..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width