简体   繁体   中英

How to insert values into the database using asp.net mvc code

I have a variable called

var xml = RestCall.xmlResult 

I want to add the value of this variable into an oracle database table.Here is the way that I followed.

"UPDATE EMPLOYEE SET RESPONSE_BODY='<wq_root>'+xml+'</wq_root>' WHERE JOB_ID=74";
dbConnection.oracleCommand.ExecuteNonQuery();

It inserts value.But I want to get the value of xml variable into the table. My ultimate result in the RESPONSE_BODY field of EMPLOYEE table should be as below.

<x_root>value of xml variable</x_root>

Remove the WHERE clause...

dbConnection.oracleCommand.CommandText = "INSERT INTO EMPLOYEE (RESPONSE_BODY) VALUES('<x_root>"+xml+"</x_root>')";
dbConnection.oracleCommand.ExecuteNonQuery();

However if you want to "insert" data into an existing row, you are looking for update instead!

dbConnection.oracleCommand.CommandText = "UPDATE EMPLOYEE SET RESPONSE_BODY = '<x_root>"+xml+"</x_root>' WHERE JOBID=74";
dbConnection.oracleCommand.ExecuteNonQuery();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM