復制代碼 代碼如下:
#region 根據動態生成的數據庫表名,從該表中選出QuestionId,ChapterId,QuestionTypeId,Point,不包括難度等級約束
/// <summary>
/// 根據動態生成的數據庫表名,從該表中選出QuestionId,ChapterId,QuestionTypeId,Point,
/// Degree,Fraction,QuestioinContent,IsValid等內容,不包括難度等級約束
/// </summary>
/// <param></param>
/// <returns></returns>
public DataTable BindQuestion(string strTableName,string strChapterName,string strQuestionTypeName)
{
try
{
DataTable dt = new DataTable ();
if (strQuestionTypeName != "論述題" && strQuestionTypeName != "案例分析題")
{
strsql = "select * from " + strTableName + " where ChapterId=@chapterid and QuestionTypeId=@questiontypeid";
}
else
{
strsql = "select QuestionId,ChapterId,QuestionTypeId,Point,Degree,Fraction,QuestionContent,cast(Answer1 as nvarchar(4000)) + cast(Answer2 as nvarchar(4000)) + cast(Answer3 as nvarchar(4000)) + cast(Answer4 as nvarchar(4000)) + cast(Answer5 as nvarchar(4000)) + cast(Answer6 as nvarchar(4000)) AS CorrectAnswer,IsValid from " + strTableName + " where ChapterId=@chapterid and QuestionTypeId=@questiontypeid";
}
//strsql = "select * from " + strTableName + " where ChapterId=@chapterid and QuestionTypeId=@questiontypeid";
SqlParameter[] paras = new SqlParameter[]{
new SqlParameter("@chapterid",strChapterName),
new SqlParameter("@questiontypeid",strQuestionTypeName)
};
dt = sqlHelper.ExecuteQuery(strsql,paras,CommandType.Text);
return dt;
}
catch
{
throw new Exception("從動態生成的數據庫表中獲取QuestionId,ChapterId,QuestionTypeId,Point失?。ú话y度等級)");
}
finally
{
sqlHelper.Close();
}
}
#endregion
新聞熱點
疑難解答
圖片精選