public List<UserBaseInfoModel> GetCityByExamId(Guid ExamID)
{
var cur_user = this.GetCurrentUser();
using (SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
SqlCommand cmd;
using (SqlTransaction trans = conn.BeginTransaction())
{
try
{
string sql = @"
SELECT u.City FROM Exam_User_Power p,dbo.User_BaseInfo u
WHERE p.ExamID=@ExamID
AND p.UserID=u.UserID
GROUP BY u.City
";
cmd = new SqlCommand(sql, conn, trans);
cmd.Parameters.AddWithValue("ExamID", ExamID);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sda.Fill(ds);
List<UserBaseInfoModel> list = (List<UserBaseInfoModel>)IListDataSet.DataSetToIList<UserBaseInfoModel>(ds, 0);
trans.Commit();
return list;
}
catch
{
trans.Rollback();
throw;
}
finally
{
conn.Close();
}
}
}
return null;
}