解决方案 »
- FFmpeg转换视频加水印问题
- 请教一个正则该怎么写的。。
- ? 我有个想法大家看看是否行得通,有关字符串压缩的!
- 怎样调用Windows Mobile PocketPC里的编写短信模块
- 物体碰撞判断2
- 当传递具有已删除行的 DataRow 集合时,更新要求有效的 DeleteCommand,加分
- 请教在vs2005中显示树控件的问题
- 急!!!急!!!急!!!KeyPressEventArgs的KeyChar
- 2004年的一个贴子,没人回复,不知道最终那位楼主解决了没有,现在我有相同的需求,大家帮下我了。
- 请问高手:C#如何通过索引设置一个对象的属性?
- GDI+ 水印错位
- 如何在TabControl中动态添加新控件,就像在IE里添加选项卡一样
后面加上
this.dataGridView1.DataBind();
//datagridview1.datasource = ds.tables["ReportText_1"];大小写不对。
报错·············"System.Windows.forms.DataGridView" 不包含"DataBind"的定义····
把"ds.tables"改成"ds.Tables"?
报错······················“System.Windows.Forms.DataGridView”并不包含“datasource”的定义··
报错·············"System.Windows.forms.DataGridView" 不包含"DataBind"的定义····
不好意思,把DataGridView看成GridView了。
是不是改成这样?
dataGridView1.DataSource = ds.Tables["ReportText_1"];
是不是改成这样?
dataGridView1.DataSource = ds.Tables["ReportText_1"];[/quote还是无法更新··
public DataSet ds = new DataSet();
public SqlDataAdapter sdr = new SqlDataAdapter();
string strSql = "select * from ReportText_1";
public SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings[1].ConnectionString.ToString());
private void button1_Click(object sender, EventArgs e)
{
//ds.Tables.Add("ReportText_1");
SqlCommandBuilder scb = new SqlCommandBuilder(sdr);
sdr.UpdateCommand = scb.GetUpdateCommand();
//sdr.InsertCommand = scb.GetInsertCommand();
//SetDataResource(); sdr.Update(ds, "ReportText_1");
} public void SetDataResource()
{
conn.Open();
sdr = new SqlDataAdapter(strSql, conn);
ds.Clear();
sdr.Fill(ds, "ReportText_1");
dataGridView1.DataSource = ds.Tables["ReportText_1"];
conn.Close(); this.dataGridView1.DataSource=null;
this.dataGridView1.DataSource = ds.Tables["ReportText_1"];
}
你把你的代码贴的全一点,不然不好判断
{
//ds.Tables.Add("RportText_1"); SqlCommandBuilder scb = new SqlCommandBuilder(sdr); //DataTable table = this.dataGridView1.DataSource as DataTable; //conn.Open();
sdr.UpdateCommand=scb.GetUpdateCommand();
//datasetresource(); sdr.Update(ds, "RportText_1"); //conn.Close(); }
public void SetDataResource()
{ conn.Open(); sdr = new SqlDataAdapter(strSql, conn); ds.Clear(); sdr.Fill(ds, "ReportText_1"); dataGridView1.DataSource = ds.Tables["ReportText_1"]; conn.Close(); this.dataGridView1.DataSource = null;
this.dataGridView1.DataSource = ds.Tables["ReportText_1"]; } /*public void datasetresource()
{ conn.Open(); sdr = new SqlDataAdapter(strSql, conn); //ds.Clear(); sdr.Fill(ds, "ReportText_1"); dataGridView1.DataSource = ds.Tables["ReportText_1"]; conn.Close(); this.dataGridView1.DataSource = null; this.dataGridView1.DataSource = ds.Tables[0];
//this.dataGridView1.DataBind(); }*/
public Form1() { InitializeComponent(); }
private void Form1_load(object sender, EventArgs e)
{// datasetresource(); }
private void button1_Click_1(object sender, EventArgs e)
{ OutPut Out = new OutPut(); Out.ShowDialog(); } private void Form1_Load_1(object sender, EventArgs e)
{ // TODO: 这行代码将数据加载到表“cpyDataSet.ReportText_1”中。您可以根据需要移动或移除它。 this.reportText_1TableAdapter1.Fill(this.cpyDataSet.ReportText_1);
} private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{ dataGridView1.Columns[0].ReadOnly = true; } private void reportViewer1_Load(object sender, EventArgs e)
{ }