c#中的DataGridView更新问题

public class Form1
{
    DataRow Drow;
   
private void // ERROR: Handles clauses are not supported in C# Form1_Load(object sender, System.EventArgs e)
    {
       
string CSx = " Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + " db3.mdb " ;
       
this .Table1TableAdapter.Connection.ConnectionString = CSx;
       
// 重新设置数据库的地址
        this .Table1TableAdapter.Fill( this .Db3DataSet1.Table1);
       
// 将数据库中的数据填充所有的绑定控件
    }
   
   
private void Button1_Click( object sender, System.EventArgs e)
    {
       
// 加记录
        string x唯一 = Strings.Format(TimeOfDay, " hhMMss " ) + DataGridView1.RowCount + 1 ;
       
// 表的第1个字段为主键,主键必须要有,不然无法保存
       
// Dim abc() As String= {x唯一, "张三", "男", 45, 78, 56, 87, 90} '准备数据
       
        Drow
= Db3DataSet1.Tables( " Table1 " ).NewRow();
        Drow(
0 ) = x唯一;
        Drow(
1 ) = " 张三 " ;
        Drow(
2 ) = " " ;
        Drow(
3 ) = 45 ;
        Drow(
4 ) = 78 ;
       
    }
   
   
   
private void Button2_Click( object sender, System.EventArgs e)
    {
       
// 更新数据库
        Db3DataSet1.Table1.Rows.Add(Drow);
        Table1TableAdapter.Update(Db3DataSet1.Table1);
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值