Question

There's a column in my database called Points with numbers and id like to set all the records in this column to zero. how would i accomplish this ?

Here's what iv done so far,

public static void clearPoints()
    {
         OleDbConnection myConnection = GetConnection();
         int count = 0;
        string myQuery1 = "Update AnswerTable  SET Points= " + count+ "'";
        OleDbCommand myCommand = new OleDbCommand(myQuery1, myConnection);

        try
        {
            myConnection.Open();
            myCommand.ExecuteNonQuery();
        }
        catch (Exception ex)
        {
            Console.WriteLine("Exception in DBHandler", ex);
        }
        finally
        {
            myConnection.Close();
        }
Was it helpful?

Solution

Adjust your query string to

string myQuery1 = "Update AnswerTable SET Points=0";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top