none
What is the differences between the two ways of connecting to a database? RRS feed

  • Question

  • Hello,

    I'm a beginner of sql server 2005.

    I know two ways of connecting to a database. One is to attach the database using sql server management studio and set the "InitialCatalog" in the connection string. The other is not to attach the database using sql server management studio and set the "AttachDbFilename".

    What is the differences between the two ways and which is better?

    Thanks.
    Tuesday, April 1, 2008 11:37 AM

Answers

  • what you are mentioned is the two type of connection string.

     

    AttachDBFilename type of connection string only works with SQL Server Express edition which is called UserInstance (embedded database) feature of SQL Server Express.

    Refer

    http://msdn2.microsoft.com/en-us/library/bb264564.aspx

     

    The other method is you are connecting to a database which already exists in an instance which is common in all the edition and version.

     

    Madhu
    Tuesday, April 1, 2008 11:51 AM
    Moderator

All replies

  • what you are mentioned is the two type of connection string.

     

    AttachDBFilename type of connection string only works with SQL Server Express edition which is called UserInstance (embedded database) feature of SQL Server Express.

    Refer

    http://msdn2.microsoft.com/en-us/library/bb264564.aspx

     

    The other method is you are connecting to a database which already exists in an instance which is common in all the edition and version.

     

    Madhu
    Tuesday, April 1, 2008 11:51 AM
    Moderator
  • However, I found it could also be used in sql server. The connection string isBig Smileata Source=(local);AttachDbFilename="D:\a.mdf";User ID=sa;Password=***********

    Tuesday, April 1, 2008 12:00 PM
  • You can use that only in SQL Server Express edition. This feature is only available in that edition. refer the link provided in earlier post

     

    Madhu

     

    Tuesday, April 1, 2008 12:02 PM
    Moderator