Reputation: 4369
I'm new to ASP.NET and trying to retrieve data set from database but I've got an error as the title says
Here is the code, What's the problem?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class Admin_addNode : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
var category = new category();
DataSet ds = new DataSet();
ds = category.getNode();
DataTable tbl = ds.Tables[0];
for (int i = 0; i < tbl.Rows.Count; i++)
{
DataRow myRow = tbl.Rows[i];
string MyValue = myRow["title"].ToString();
Response.Write(MyValue);
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
}
}
protected void Button1_Click in which "void" is red underlined in vwd
Upvotes: 0
Views: 1577
Reputation: 734
The first answer you set you free from one problem, but I think there might be other, like this:
DataSet ds = new DataSet(); ds = category.getNode();
You are creating a new DataSet then you are assigning to it something else retrieved from the method getNode(), which I suppose return another DataSet, so you lose the first one.
The way it is, it will run but you will be creating an unnecessary DataSet instance.
DataSet ds = category.getNode()
Upvotes: 1