为什么方法不能使用数据集从数据库中向我发送值?
错误示例
public string dane()
{
// Get the DataTable of a DataSet.
DataTable table = DataSet1.Tables["Products"];
DataRow[] rows = table.Select();
string s ="";
// Print the value one column of each DataRow.
for (int i = 0; i < rows.Length; i++)
{
s += rows[i]["ProductID"] + " ";
}
return s;
}
错误 - 非静态字段、方法或属性需要对象引用
找不到数据。(但错误已修复)
public string dane()
{
// Get the DataTable of a DataSet.
DataSet1 dataSet = new DataSet1();
DataTable table = dataSet.Tables["Products"];
DataRow[] rows = table.Select();
string s ="";
// Print the value one column of each DataRow.
for (int i = 0; i < rows.Length; i++)
{
s += rows[i]["ProductID"] + " ";
}
return s;
}