我已經安裝了SQL Server 2008 Express,並試圖從C#訪問它。設置SQL Server 2008,我如何使用SqlConnection從C#訪問它?
我不太確定我在SQL Server Management Studio中正確設置了它。我有一個密碼和一個.sdf文件。目前數據庫中沒有任何內容。這是我在C#中的代碼片段。
SqlConnection userSqlData = new SqlConnection("Data Source = localhost;database=UserData;Password=Mine;connection timeout = 10");
try
{
userSqlData.Open();
}
catch
{
MessageBox.Show("Failed");
}
連接總是超時。很明顯,我在這裏設置了錯誤。我如何獲得它連接到本地計算機上的數據庫?
A .sdf文件是SQL Server **精簡版**(CE)的數據庫文件 - **不是** SQL Server Express ...... –