locked
connection string not familiar RRS feed

  • Question

  • I am beginner in C sharp. I have downloaded a project from internet its connection string is like below:-

    public const string  strConn = "server=ZAMAN; uid=hmdba; pwd=123456; database=hoteldb;";

    I have restored the database in sqlserver2005 with name hoteldb and change my pc name like ZAMAN.

    I am working with visual studio 2008.But I still cannot establish the connection with the database.

    I am not familiar with this connection string type. Because I have worked before with the connection string like below:-

    Data Source = abc-PC\\SQLEXPRESS; Initial Catalog=abcdb; Integrated Security=true

    Please any body help.


    sayedsust
    Saturday, March 5, 2011 12:51 PM

Answers

  • You've mounted the database on a local instance of SQL Server, correct?

    Can you connect using the second format you show? "Data Source = abc-PC\\SQLEXPRESS; Initial Catalog=abcdb; Integrated Security=true"

    The first example "public const string  strConn = "server=ZAMAN; uid=hmdba; pwd=123456; database=hoteldb;";"

    looks like a connection string for a database on a remote server.

    FWIW, there is a forum dedicated to data access issues for developers, here:

    http://social.msdn.microsoft.com/Forums/en-US/vstsdb/threads

     

     

    • Edited by pvdg42 Saturday, March 5, 2011 2:51 PM add info
    • Proposed as answer by eryang Monday, March 7, 2011 7:24 AM
    • Marked as answer by eryang Tuesday, March 15, 2011 3:05 AM
    Saturday, March 5, 2011 2:48 PM

All replies

  • You've mounted the database on a local instance of SQL Server, correct?

    Can you connect using the second format you show? "Data Source = abc-PC\\SQLEXPRESS; Initial Catalog=abcdb; Integrated Security=true"

    The first example "public const string  strConn = "server=ZAMAN; uid=hmdba; pwd=123456; database=hoteldb;";"

    looks like a connection string for a database on a remote server.

    FWIW, there is a forum dedicated to data access issues for developers, here:

    http://social.msdn.microsoft.com/Forums/en-US/vstsdb/threads

     

     

    • Edited by pvdg42 Saturday, March 5, 2011 2:51 PM add info
    • Proposed as answer by eryang Monday, March 7, 2011 7:24 AM
    • Marked as answer by eryang Tuesday, March 15, 2011 3:05 AM
    Saturday, March 5, 2011 2:48 PM
  • Hi,

    if you have restore the database on local system then you can use the connection string as follows

    Data Source = localhost; Initial Catalog=abcdb; Integrated Security=true

     

    If you are using sql authentication then you have to specify the user name and password in the connection string.


    Thanks, Pranil Yambal | MCTS | Pranil.Yambal@hotmail.com
    Saturday, March 5, 2011 3:30 PM