locked
VC++ fails to connect to SQL Express RRS feed

  • Question

  • Hi , have a database on sqlexpress 2005 that I would like to use from vs 2008 c++.  Using :

     

    String ^ connectString = "Data Source=localhost;Database=sqlexpress\\FAR_HISTORY;UID=eclipz;Password=litespeed";

    SqlConnection^ sqlconn = gcnew SqlConnection(connectString);

    sqlconn->Open();

     

    and it fails:  Additional information: Login failed for user 'eclipz'. I have the user id  created under the "security tab" in SQL Server Management Studio express with the correct DB.

     

     

    Next I tried Database="Trusted_Connection=yes............."

     

     It fails again.

     

    But If I try connecting to the Northwind  DB created under MSDE 2000 using the "sa" account it logins ok !!!!!! 

     

    Help?

     

    Monday, February 11, 2008 10:12 PM

Answers

  • You may want to use:

     

    "Source=localhost\\SQLEXPRESS;Database=FAR_HISTORY;UID=eclipz;Password=litespeed";

     

    If you installed it as "default instance", try:

     

    "Source=localhost;Database=FAR_HISTORY;UID=eclipz;Password=litespeed";

     

    This is assuming that you did not actually create your database with:

     

    create database sqlexpress\far_history.

     

    Hope that helps,

     

    John

    Monday, February 11, 2008 10:27 PM

All replies

  • You may want to use:

     

    "Source=localhost\\SQLEXPRESS;Database=FAR_HISTORY;UID=eclipz;Password=litespeed";

     

    If you installed it as "default instance", try:

     

    "Source=localhost;Database=FAR_HISTORY;UID=eclipz;Password=litespeed";

     

    This is assuming that you did not actually create your database with:

     

    create database sqlexpress\far_history.

     

    Hope that helps,

     

    John

    Monday, February 11, 2008 10:27 PM
  • Thanks John !

     

    Tried both suggestions with no luck. I created the database via VS2008 not thru sqlcmd utilities.

    Monday, February 11, 2008 10:43 PM