我在C#编码但是有一个错误我实际上无法解决,也许有人可以帮助我!
对不起我的英语,我不是母语人士!
这是我的代码:
public List<Materiel> GetAllTubas()
{
DataAccess.Oradb getListTubas = new DataAccess.Oradb();
getListTubas.GetTubaDatabase(null);
List<Materiel> ListMateriel = new List<Materiel>();
foreach(DataRow row in dt.Rows) //the name "dt" does not exist in the current context {
var myListTuba = new Materiel();
myListTuba.Nom = row["nom_tuba"];
ListMateriel.Add(myListTuba);
}
return ListMateriel;
}
Run Code Online (Sandbox Code Playgroud)
在这个方法中我调用另一个方法GetTubaDatabase; 连接到数据库和SQL查询,它返回我的DataTable dt填充我的查询结果.现在我想通过我的Datatable创建一个List,但是会出现一个错误:当前上下文中不存在名称"dt"(大约从我的mothertongue翻译)
我认为这不是一个巨大的错误,但我无法解决它,也不知道我怎么做.
希望你能帮助我!
非常感谢 !