net操作access数据库示例分享(2)

/// <summary>
    /// update
    /// </summary>
    /// <param></param>
    /// <param></param>
    private void button2_Click(object sender, EventArgs e)
    {
        //1、建立连接
        string sAccessConnection = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator.WWW-410ADC78208\桌面\应用程序.mdb";
        OleDbConnection odcConnection = new OleDbConnection(sAccessConnection);
        //2、打开连接
        odcConnection.Open();
        //建立SQL查询
        OleDbCommand odCommand = odcConnection.CreateCommand();
        //3、输入查询语句
        string sql = "UPDATE [table] SET 123='11',456='11'  WHERE (((table.编号)=" + this.listView1.SelectedItems[0].SubItems[1].Text + "))";
        odCommand.CommandText = sql;
        //执行
        odCommand.ExecuteNonQuery();
        //关闭连接
        odcConnection.Close();
        this.listView1.Items.Clear();
        ReadAccessData();
    }
}

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjzxjp.html