Dapper with MS Access Update and Insertion

I am using Dapper to update and insert an access database. The code works without causing an exception, but without updating the value in the database. Below is my code

sql.Append("UPDATE drugs_repository SET drug_name = @DrugName "); sql.Append(" WHERE id = @DrugId"); var parameters = new { DrugName = objDrug.DrugName, DrugId = objDrug.DrugId }; var t = connection.Query<string>(sql.ToString(), parameters); 

Can someone please let me know what exactly I am missing in the above code? When I rigidly set the value, than updating it in the database. This is probably due to the parameter.

+3
c # ms-access dapper
source share
1 answer

If you are nervous about the possible side effects of removing .OrderBy() in Dapper code, then a workaround would be to name your parameters so that they are sorted in the same order that they appear in the SQL command, For example, I suspect that unmodified Dapper code is likely to work fine if the parameters were named @1DrugName and @2DrugId .

+2
source share

All Articles