asp.net - updating a row gives error Operation must use an updateable query -


i'm getting error when i'm trying update record:

error [hy000] [microsoft][odbc microsoft access driver]

operation must use updateable query

however when add new record, add fine.

i did searching , found out problem because asp.net worker process not have permission update database. how being able insert new record (isn't inserting updating database!) not update (set record different value).

odbcconnection dbconnection = new odbcconnection("dsn=inv"); dbconnection.open();  try {     string newpassword = password1.text;     odbccommand dbcommand = new odbccommand("update users" + " set [password] = '" + newpassword + "'" + " name = '" + session["loginid"] + "'" + ";", dbconnection);     dbcommand.executenonquery();     server.transfer("default.aspx", true); } 

you error if don't have primary key declared on table.

your code pretty ugly, @ least should using parameterized query:

odbccommand dbcommand = new odbccommand("update users set [password] = @password name = @name", dbconnection); var param = dbcommand.parameters.add("@password", odbctype.text); param.value = password; param = dbcommand.parameters.add("@name", odbctype.text); param.value = session["loginid"]; 

and hope isn't more toy/demo app -- storing passwords in clear bad. storing passwords in access in clear double bad.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -