LocalDB - 在LocalDB建立資料庫產生錯誤

  • 2475
  • 0

LocalDB - 在LocalDB建立資料庫產生錯誤

至從有了LocalDB後,Windows Azure的模擬器使用LocalDB,開發專案也不再使用SQL Server Express或是SQL Server Compact,全部都改用好用的LocalDB。

不過前幾天要在LocaDB上面建立一個資料庫,卻失敗,如下。

image

錯誤訊息如下。

資料庫 'Test' 的 建立 失敗。  (Microsoft.SqlServer.Smo)

執行 Transact-SQL 陳述式或批次時發生例外狀況。 (Microsoft.SqlServer.ConnectionInfo)

A file activation error occurred. The physical file name 'Test.mdf' may be incorrect. Diagnose and correct additional errors, and retry the operation.
CREATE DATABASE failed. Some file names listed could not be created. Check related errors. (Microsoft SQL Server, 錯誤: 5105)

後來查了一下資料,原來是因為路徑沒給…( 雖然上面是寫預設路徑… )

image

解決的方法很簡單,只要指定一下路徑就可以了。

image

這樣就完成啦!!

後記

雖然這篇文章很短,但希望能幫助到剛好遇到問題的人=V=,最後,也感謝Terry哥的這篇文章,讓小弟可以很快地使用指令控制LocalDB喔!!

參考資料