I'm using Microsoft Access file as database. I have no problem with SELECT
and INSERT
queries but when I try to UPDATE
, record in database does not change.
Below is the code I use to run update. There are no exceptions or errors in debug log.
cnn = new OleDbConnection(connetionString);
OleDbCommand command = new OleDbCommand("UPDATE [Wpisy] SET [wpis]=@wpis, [id_kat]=@id_kat, [tytul]=@tytul WHERE [ID]=@id_wpis" , cnn);
command.Parameters.Add(new OleDbParameter("@wpis", tresc_wpisu.Text));
command.Parameters.Add(new OleDbParameter("@id_kat", lista_kategorii.SelectedValue));
command.Parameters.Add(new OleDbParameter("@tytul", tytul_wpisu.Text));
command.Parameters.Add(new OleDbParameter("@id_wpis", Request["id"].ToString() ));
command.Connection = cnn;
try
{
if(cnn.State.ToString() != "Open")
cnn.Open();
command.ExecuteNonQuery();
cnn.Close();
}
catch (OleDbException ex)
{
Response.Clear();
Response.Write(ex);
Response.End();
}
Request["id"]
contain value for parameter@id_wpis
and does your update execute properly in database? – HaferRequest["id"]
contains proper value and there is no error. – TheobaldRequest["id"]
exist inWipsy
table? – Haferid=10
in URL. inWpisy
table I have record with that value inID
column – Theobald