“Illegal characters in path (mscorlib)” when trying to Attach Database in SQL Server 2005

corruptionsql-server-2005

I am trying to Attach a database in SQL Server 2005, and get the following error:

===================================

Illegal characters in path. (mscorlib)

------------------------------
Program Location:

   at System.IO.Path.CheckInvalidPathChars(String path)
   at System.IO.Path.GetFileName(String path)
   at Microsoft.SqlServer.Management.SqlManagerUI.AttachDatabaseData.PrimaryFile.PopulateAssociatedFiles(String primaryFilePath)
   at Microsoft.SqlServer.Management.SqlManagerUI.AttachDatabaseData.PrimaryFile.PopulatePrimaryFileData(String primaryFilePath)
   at Microsoft.SqlServer.Management.SqlManagerUI.AttachDatabaseData.PrimaryFile..ctor(SqlManagementUserControl parent, CDataContainer dc, String fullPath, String databaseOwner, ServerConnection connectionInfo)
   at Microsoft.SqlServer.Management.SqlManagerUI.AttachDatabase.IsSelectedFileValid(BrowseFolder dlg)

The path is "E:\Database\DB_Data.MDF" so it should be fine. I fear data corruption. Any ways to look deeper into the file and see if I can get my data out?

UPDATE:
Data is corrupt. Any ways to check individual partitions or get some of the data back?
Here is the results from sp_attach_db:

Msg 5120, Level 16, State 5, Line 1
Unable to open the physical file "                           E:\Database\NationalDatabase_Log.LDF". Operating system error 2: "2(The system cannot find the file specified.)".
Msg 5120, Level 16, State 5, Line 1
Unable to open the physical file "                                                                                                                                                Ѐ". Operating system error 2: "2(The system cannot find the file specified.)".
Msg 5120, Level 16, State 5, Line 1
Unable to open the physical file "                                      䔀㨀尀䐀愀琀愀戀愀猀攀尀一愀琀椀漀渀愀氀䐀愀琀愀戀愀猀攀开䐀愀琀愀⸀䴀䐀䘀                                                                                                                                                                                         ". Operating system error 2: "2(The system cannot find the file specified.)".
Msg 1813, Level 16, State 2, Line 1
Could not open new database 'NationalDatabase'. CREATE DATABASE is aborted.

Best Answer

Perhaps try to run SQL Server's stored proc to attach the DB:

From MSDN:

EXEC sp_attach_db @dbname = N'MyDatabase', 
    @filename1 = N'E:\Database\DB_Data.MDF', 
    @filename2 = N'E:\Database\DB_Data_log.LDF';