本文介绍了纳撒尼尔·德洛斯·雷耶斯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


如何编辑和删除数据库中的数据

how to edit and delete data in database

推荐答案


public const string DB_CONN_STRING =
        "Driver={Microsoft Access Driver (*.mdb)}; "+
        "DBQ=D:\\CS\\TestDbReadWrite\\SimpleTest.mdb";


    // Edit SQL command
    String sSQLCommand = "UPDATE Person SET Age = 27 WHERE FirstName = 'Peter'";
    // Create the command object
    ADOCommand cmdAdder = new ADOCommand(
        sSQLCommand,
        DB_CONN_STRING);
    cmdAdder.ActiveConnection.Open();
    // Execute the SQL command
    int nEdit = cmdAdder.ExecuteNonQuery();
    System.Console.WriteLine( "\nRow(s) Added = " + nEdit + "\n" );


    // Delete SQL command
    String sSQLCommand = "DELETE FROM Person WHERE FirstName = 'Bobo'";
    // Create the command object
    ADOCommand cmdAdder = new ADOCommand(
        sSQLCommand,
        DB_CONN_STRING);
    cmdAdder.ActiveConnection.Open();
    // Execute the SQL command
    int nDel = cmdAdder.ExecuteNonQuery();


这篇关于纳撒尼尔·德洛斯·雷耶斯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-25 23:05