Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 用MySQL数据填充ArrayList_C#_Mysql_Asp.net_Arraylist_Datareader - Fatal编程技术网

C# 用MySQL数据填充ArrayList

C# 用MySQL数据填充ArrayList,c#,mysql,asp.net,arraylist,datareader,C#,Mysql,Asp.net,Arraylist,Datareader,我试图用数据库中的字段('answer'和'answer\u id')填充两个ArrayList(ListofAnwers和ListofAnweris) 当字符串cmdText中的问题_id=1时,以下代码似乎工作得非常好。但是,如果我将其更改为2或3,ArrayList将保持为空,我不知道为什么。有什么想法吗 我认为这与字符串cmdGetAnswersQuery有关,它是“从问题\u id=2的答案中选择*” 实际数据库内容如下所示: 我不能肯定这就是问题所在,但我首先要看的是这行代码: cm

我试图用数据库中的字段('answer'和'answer\u id')填充两个ArrayList(ListofAnwers和ListofAnweris)

当字符串cmdText中的问题_id=1时,以下代码似乎工作得非常好。但是,如果我将其更改为2或3,ArrayList将保持为空,我不知道为什么。有什么想法吗

我认为这与字符串cmdGetAnswersQuery有关,它是“从问题\u id=2的答案中选择*”

实际数据库内容如下所示:
我不能肯定这就是问题所在,但我首先要看的是这行代码:

cmdGetAnswers.Parameters["@QuestionID"].Value = ViewState["AnswerID"];

我想你希望它是
ViewState[“QuestionID”]

嗯,我不想问,但是。。。是否有任何行的
question\u id=2
question\u id=3
?@Jashaszun Yeah-,年份2k14,我们仍在使用
ArrayList
?@MatíasFidemraizer编码,因此我用列表替换了ArrayList,但仍然存在相同的问题。这行代码看起来可疑:
cmdGetAnswers.Parameters[“@QuestionID”].Value=ViewState[“AnswerID”]。这不应该是
ViewState[“QuestionID”]
?除非问题ID和答案ID是一样的。此外,您的第一个查询设置了一个查询中从未使用过的
ModuleID
参数。这是以前代码的产物,还是错误?
cmdGetAnswers.Parameters["@QuestionID"].Value = ViewState["AnswerID"];