vs2013 使用 ODP.NET連線至 oracle database
要新增一筆資訊到table中
發生了 ORA-01745: invalid host/bind variable name 錯誤
public static void AddCasstteHisoty(string casstteid, string userid)
{
string sql = "insert into csthis values(:casstteid, :transactiontype, :inserttime, :userid, :action, :comment)";
OracleCommand command = new OracleCommand(sql);
command.Parameters.Add("casstteid", OracleDbType.Char).Value = casstteid;
command.Parameters.Add("transactiontype", OracleDbType.Char).Value = "LOC1";
command.Parameters.Add("inserttime", OracleDbType.Char).Value = DateTime.Now.ToString("yyyyMMddHHmmss");
command.Parameters.Add("userid", OracleDbType.Char).Value = userid;
command.Parameters.Add("action", OracleDbType.Char).Value = "update casstte location from android app";
command.Parameters.Add("comment", OracleDbType.Char).Value = " ";
int count = 0;
DBAdapter.ExcuteNonQueryCommand(command, out count);
}
在sql 字串裡 有個 :comment
這個是oracle 保留字
所以就引發這個錯誤
修改方式把comment改成其他字串,這裡我改成leavecomment