public bool ConnectToDB()
{
SqlConnection sqlConnect = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnection"].ToString());
try
{
sqlConnect.Open();
if (sqlConnect.State == ConnectionState.Open)
{
return true;
}
}
catch (SqlException ex)
{
// some code here...
}
finally
{
sqlConnect.Close();
}
}
當我運行這段代碼,它給了一個錯誤錯誤在asp.net返回值
錯誤「DataAccess.ConnectToDB()」:不是所有的代碼路徑返回一個值
@AshBurlaczenko我建議你學習.NEt。立即 –