reportview 数据更新的问题
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Configuration;
using Microsoft.Reporting.WinForms;
using System.Management;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“Database1DataSet1.Message”中。您可以根据需要移动或移除它。
this.MessageTableAdapter.Fill(this.Database1DataSet1.Message);
ReportDataSource myRD = new ReportDataSource( "Database1DataSet1_Message ", LoadMessageData());
this.reportViewer1.LocalReport.DataSources.Add(myRD);
this.reportViewer1.RefreshReport();
}
public DataTable LoadMessageData()
{
string strcon = ConfigurationManager.ConnectionStrings[ "WindowsApplication2.Properties.Settings.Database1ConnectionString "].ToString();
SqlConnection sqlCon = new SqlConnection(strcon);
DataSet myds = new DataSet();
sqlCon.Open();
string strCOM = "select * from Message ";
SqlDataAdapter myAdapter = new SqlDataAdapter(strCOM, sqlCon);
myAdapter.Fill(myds, "Message ");
return myds.Tables[0];
}