0
我使用下面的代碼連接到Microsoft SQL Server數據庫,但我總是得到一個錯誤如何解決異常「類型的第一次機會異常」時
var conn = @"Server=(local)\localhost;Database=Training;";
using (SqlConnection objSqlConnection = new SqlConnection(conn))
{
try
{
objSqlConnection.Open();
Console.Write("Connection is successfull");
}
catch (System.Data.SqlClient.SqlException sqlException)
{
Console.WriteLine(sqlException.Message);
}
}
,我得到的錯誤是:
A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
The thread 'vshost.RunParkingWindow' (0xd28) has exited with code 0 (0x0).
The thread '<No Name>' (0x1550) has exited with code 0 (0x0).
The program '[6440] DataAccess.vshost.exe: Managed (v4.0.30319)' has exited with code 0 (0x0).