如何使用SqlCeDataAdapter编辑datagridview?

时间:2010-03-09 03:33:27

标签: c# datagridview sql-server-ce

我有一个与datagridview绑定的frmEdit:

string sqlqry1 = "select p_Name from Items where p_Id=" + p_Id;
        using (SqlCeDataAdapter a = new SqlCeDataAdapter(sqlqry1, conn))
        {
            DataTable dt1 = new DataTable();
            a.Fill(dt1);
            dataGridView1.DataSource = dt1;
        }

如何编辑单元格并将其保存回db ?,尝试使用:

using (SqlCeDataAdapter a = new SqlCeDataAdapter(sqlqry1, conn))
        {
            DataTable dt1 = new DataTable();
            a.Fill(dt1);
            dataGridView1.DataSource = dt1;
            a.Update(dt1);
        }

无。

还有吗?。

2 个答案:

答案 0 :(得分:1)

找到解决方案:

        SqlCeDataAdapter da;
        SqlCeCommandBuilder cmdBuilder;


        da = new SqlCeDataAdapter("select * from Items", conn);
        cmdBuilder = new SqlCeCommandBuilder(da);
        da.Fill(myDatabaseDataSet, "Items");
        myDatabaseDataSet.Tables["Items"].Rows[0]["p_Name"] = dataGridView1.Rows[0].Cells["p_Name"].Value.ToString();
        da.Update(myDatabaseDataSet, "Items"); 

答案 1 :(得分:0)

$(".datepicker").datepicker({
    beforeShowDay: function (date) {
        var datestring = jQuery.datepicker.formatDate('yy-mm-dd', date);
        if (datestring != '') {
            return [disableddates.indexOf(datestring) == -1];
        }
        <?php if(isset($delivery_date_setting -> delivery_days_sunday) 
                 && $delivery_date_setting ->delivery_days_sunday == '1') { ?>

        if (date.getDay() == 0) {
            return [true, ''];
        }
    }
});

使用工作示例重新启用此功能,因为此页面在Google上排名。