Updating A Database Record in ASp.NEt 2.0

Nov 4 2006 6:38 AM
Hi,

I have encountered a strange problem when trying to update a microsoft access database record with ASP.NET 2.0 - C#.  I can already Insert and view records but the update doesnt seem to be working at all.  Here is a simple segment of my code:

protected void btnUpdate_Click(object sender, EventArgs e)

{

OleDbConnection objConn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" + Server.MapPath("/admin/App_Data/DataSynapseAdmin.mdb") + ";");

OleDbCommand objCmd = new OleDbCommand("UPDATE Hospital SET name = @hospitalName WHERE hospitalID = 26", objConn);

OleDbParameter hospitalName = new OleDbParameter("@hospitalName", txtHospitalName.Text);

objCmd.Parameters.Add(hospitalName);

objConn.Open();

objCmd.ExecuteNonQuery();

objConn.Close();

objConn.Dispose();

}

Am I missing an improtant factor?  Any help appreciated.

columth06.


Answers (1)