我在实验dataset和dataReader的相关应用,源代码如下,可是出错using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;namespace dataset5
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid myDataGrid;
private static string ConnectionString="DataSource=GPTEACHER;database=Northwind;uid=sa;pwd=sa;";
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
CreateDataSetObject();
} // Put user code to initialize the page here
}
private void CreateDataSetObject()
{
SqlConnection myConnection=new SqlConnection(ConnectionString);
String cmdText="select top 8* from Customers";
SqlCommand myCommand=new SqlCommand(cmdText,myConnection);
myConnection.Open();
DataTable tabel=new DataTable("Customers");
tabel.Columns.Add("Index");
tabel.Columns.Add("CustomerID");
tabel.Columns.Add("CompanyName");
SqlDataReader recm=myCommand.ExecuteReader();
int index=0;
while(recm.Read())
{
DataRow row=tabel.NewRow();
row["index"]=(++index).ToString();
row["CustomerID"]=recm["CustomerID"].ToString();
row["CompanyName"].ToString();
tabel.Rows.Add(row);
}
recm.Close();
myConnection.Close();
===>>这里出错:myDataGrid.DataSource =new DataSet(tabel);
myDataGrid.DataBind();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{    
this.Load += new System.EventHandler(this.Page_Load); }
#endregion
}
}出错说明如下:
C:\Inetpub\wwwroot\aspx\dataset5\WebForm1.aspx.cs(55): 与“System.Data.DataSet.DataSet(string)”最匹配的重载方法具有一些无效参数C:\Inetpub\wwwroot\aspx\dataset5\WebForm1.aspx.cs(55): 参数“1” : 无法从“System.Data.DataTable”转换为“string”