不可发言的成员不能像方法一样使用
问题描述:
我的代码在下面.
my code is below.
protected void Page_Load(object sender, EventArgs e)
{
ReportDocument rptDoc=new ReportDocument();
DataSet_example ds =new DataSet_example();
SqlConnection conn=new SqlConnection();
conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["con1"].ConnectionString;
DataTable dt=new DataTable();
dt.TableName="Crystal report example";
SqlDataAdapter da=new SqlDataAdapter("Select * from sample",conn);
da.Fill(dt);
ds.Tables(0).Merge(dt);
rptDoc.Load(Server.MapPath("CrystalReport.rpt"));
rptDoc.SetDataSource(ds);
CrystalReportViewer1.ReportSource=rptDoc;
}
错误是用粗体线表示的,无法使用成员"Dataset_example.tables"不能像方法那样使用.dataset_example是数据集名称(.xsd).有谁能帮帮我吗?
< edit>添加了代码块
error is at bold line that is Non-invocable member ''Dataset_example.tables'' cannot be used like a method.where dataset_example is the dataset name(.xsd).can any one help me out?
<edit>Added Code Block
答
您可能打算写ds.Tables[0]
.
现在再次查看错误消息,尝试找出最初不清楚的地方.—SA
You probably meant to writeds.Tables[0]
.
Now look at the error message again and try to figure out, what was unclear in first place.—SA
我认为您需要编写以下突出显示的行
I think you need to write the highlighted line as below
ds.Tables[0].Merge(dt);
注意方括号.
希望对您有帮助
Milind
Note the sqaure bracket.
Hope that helps
Milind