在C#中,我TRY..CATCH..FINALLY在代码中使用了一个围绕执行存储过程的块.
如果有例外,那么FINALLY我想要关闭读者 - PolicyResult以及连接.
但是,我收到一个错误
PolicyResult名称在当前上下文中不存在
PolicyResult是在中定义的DataReader,TRY但似乎在该FINALLY部分中未被识别.
为什么?
public static IEnumerable GetPolicies(int? MasterPkgID)
{
// Create a list of policies belonging to the master package.
List<AdditionalInterestPolicyData> additionalInterestPolicyData = new List<AdditionalInterestPolicyData>();
// Set the SQL connection to the database.
SqlConnection objConn = new SqlConnection(ConfigurationManager.ConnectionStrings["QUESTIONNAIRE2"].ConnectionString);
try
{
// Open the connection.
objConn.Open();
// Get the list of policies by executing a stored procedure.
SqlCommand PolicyCmd = new SqlCommand("p_expapp_get_policy_detail_by_master_pkg", objConn);
PolicyCmd.Parameters.Clear();
PolicyCmd.CommandType = …Run Code Online (Sandbox Code Playgroud) c# ×1