unable to update a table on a access database [modified]
-
hi all, Any ideas as to why the database is not being updated will be greatly appreciated! It is driving me mad...and I just can't see what i am doing wrong :confused: string dId = "Golden"; string dCharge = "150"; OleDbConnection connectDb = new OleDbConnection(db); connectDb.Open(); OleDbCommand update = new OleDbCommand("UPDATE ShippingCharges SET Charge = ? WHERE ShippingID = ?", connectDb); update.Parameters.Add("@ShippingID", OleDbType.Char).Value = dId; update.Parameters.Add("@Charge", OleDbType.Integer).Value = dCharge; update.ExecuteNonQuery(); connectDb.Close(); -- modified at 12:18 Saturday 1st December, 2007
-
hi all, Any ideas as to why the database is not being updated will be greatly appreciated! It is driving me mad...and I just can't see what i am doing wrong :confused: string dId = "Golden"; string dCharge = "150"; OleDbConnection connectDb = new OleDbConnection(db); connectDb.Open(); OleDbCommand update = new OleDbCommand("UPDATE ShippingCharges SET Charge = ? WHERE ShippingID = ?", connectDb); update.Parameters.Add("@ShippingID", OleDbType.Char).Value = dId; update.Parameters.Add("@Charge", OleDbType.Integer).Value = dCharge; update.ExecuteNonQuery(); connectDb.Close(); -- modified at 12:18 Saturday 1st December, 2007
mocasu wrote:
update.Parameters.Add("@ShippingID", OleDbType.Char).Value = dId; update.Parameters.Add("@Charge", OleDbType.Integer).Value = dCharge;
shouldn't the update command be "Update ShippingCharges set Charge = @Charge where ShippingID = @ShippingID" if you call your updateParameters like that?
-
mocasu wrote:
update.Parameters.Add("@ShippingID", OleDbType.Char).Value = dId; update.Parameters.Add("@Charge", OleDbType.Integer).Value = dCharge;
shouldn't the update command be "Update ShippingCharges set Charge = @Charge where ShippingID = @ShippingID" if you call your updateParameters like that?
-
hi all, Any ideas as to why the database is not being updated will be greatly appreciated! It is driving me mad...and I just can't see what i am doing wrong :confused: string dId = "Golden"; string dCharge = "150"; OleDbConnection connectDb = new OleDbConnection(db); connectDb.Open(); OleDbCommand update = new OleDbCommand("UPDATE ShippingCharges SET Charge = ? WHERE ShippingID = ?", connectDb); update.Parameters.Add("@ShippingID", OleDbType.Char).Value = dId; update.Parameters.Add("@Charge", OleDbType.Integer).Value = dCharge; update.ExecuteNonQuery(); connectDb.Close(); -- modified at 12:18 Saturday 1st December, 2007
The parameters need to be added in the correct order. Even when named.
-
The parameters need to be added in the correct order. Even when named.
-
Glad to be of service.