deleting from database

Hi

I have created a database application in C# compact framework and have rows adding to my database. Now I have problems getting the data back out of the database. Is there any way to just set fields in the database just equal to a text field. through research carried out all the other programs were putting the results in a listbox, this doesnt suit my application.

I have the SQL statement sorted

Thanks for any assistance



Answer this question

deleting from database

  • Ginolard

    If you prefer to work with data in the database directly without loading it first into DataSet, you can do so by executing appropriate commands.Here's how to delete/insert/update rows (I’m assuming you’re using SQL Mobile, but it’s pretty much the same for any other database):

    SqlCeConnection conn = new SqlCeConnection(YourConnectionStringHere);
    conn.Open();

    SqlCeCommand cmd = conn.CreateCommand();
    cmd.CommandText = "Your Delete/Insert/Update Command Here Possibly With Parameters"; cmd.ExecuteNonQuery();

    Here's how to read data from database:

    SqlCeConnection conn = new SqlCeConnection(YourConnectionStringHere);
    conn.Open();

    SqlCeCommand cmd = conn.CreateCommand();
    cmd.CommandText = "Your Select Command Here";
    SqlCeDataReader reader = cmd.ExecuteReader();

    while (reader.Read()) {

    object myDataFromRowZero = reader[0];

    // Access other data here,

    }



  • deleting from database