Home Forums SQL Server 2008 SQL Server 2008 - General Cannot open database “” requested by the login. The login failed. Login failed for user 'sa' RE: Cannot open database “” requested by the login. The login failed. Login failed for user 'sa'

  • AndrewSQLDBA (2/25/2013)


    I see now, that entire path statement is your database name. You do not name the database as a path statement to a file. SQL does not work that way. You simply name the database a single, descriptive name. Like "Recipe" or "ClubMembers" The database name is only a name that you will refer too. Now, if you place that entire path statement name as the name of your database, in your connection string, you will be able to connect successfully. But I would be that you will have a time trying to use a path statement in the connection string, without some sort of escape character.

    Rename the database to a normal name.

    Andrew SQLDBA

    Thanks, but how should i do that, I didnt even change the name myself in first place!! after attaching it inside SSMS it showed up like that! and the filename is dbNegin.mdf as well , i have no idea where that name is come from!!

    ------------

    And by the way i changed the connection string as you said, now parts of program connect to the database and some others generate an error , i captured a short video demonstrating the probelm here it is :

    This is the code for the first section which works :

    DataTable table = DBAPI.BatchRead("tblManbaa", "SELECT * FROM tblManbaa Where Status = 1");

    And this is the code for the second part which fails:

    gridview.DataSource = DBAPI.ExecuteSqlFunction("dbo.GetListOfFOroshbID", new string[] { API.CurrentSourceID, ID, "1" });

    here is the video i took:

    http://upload.ustmb.ir/do.php?filename=26_13capture-1.rar

    or

    http://upload.ustmb.ir/uploads/26_13capture-1.rar