yoad
yoad

Reputation: 95

How to use SqlDataAdapter for update in local DB?

I'm trying to update, but it does not work, no throwing exception, but it does not update,. I use local DB, I was helped here.

In the past I did update with oledb in MS Access. I tried also with oldb and did not work, maybe because local DB?

Thank you.

    try {

    SqlCommand command = new SqlCommand("UPDATE Table1 SET WordsType = @wordsType WHERE ID = @id", cn_connetion);

    //SqlDataAdapter adapter = new SqlDataAdapter(); //edited
    command.Parameters.AddWithValue("@wordsType", wordsType);
    command.Parameters.AddWithValue("@id", id);
         
    if (cn_connetion.State != System.Data.ConnectionState.Open)
    {
        cn_connetion.Open();
    }

    //adapter.UpdateCommand = command; 
    command.ExecuteNonQuery();
    }

Upvotes: 0

Views: 78

Answers (0)

Related Questions