我尝试不使用Entity Framework或Procedures将数据发布到Oracle db。但是尝试使用Fiddler或Mobile应用程序访问HTTP 500时,我一直收到HTTP 500。下面是我正在尝试的代码,但是我不确定这是否会完成。任何建议表示赞赏。
[HttpPost]
[ActionName("InsertData")]
public HttpResponseMessage Post(DataClass DataClass)
{
string connStr = ConfigurationManager.AppSettings.Get("ConnString");
using (var conn = new OracleConnection(connStr))
{
conn.Open();
OracleCommand cmd = new OracleCommand();
string InsertCommand = "INSERT INTO OracleTable (DATA_ID1,DATA_ID2,DATA_ID3)" +
"Values (@DATA_ID1,@DATA_ID2,@DATA_ID3)";
cmd.CommandText = InsertCommand;
cmd.Connection = conn;
cmd.Parameters.Add(new OracleParameter("@DATA_ID1", DataClass.DATA_ID1));
cmd.Parameters.Add(new OracleParameter("@DATA_ID2", DataClass.DATA_ID2));
cmd.Parameters.Add(new OracleParameter("@DATA_ID_3", DataClass.DATA_ID_3));
cmd.ExecuteNonQuery();
conn.Close();
}
return new HttpResponseMessage(HttpStatusCode.OK);
}