When I try to add data into the database, I get this error. Certain information I obtain, gets added to the other tables I have created. This problem occurs only regarding one table.
Here's my code :
public class NewOtherCompanyMapper
{
OtherCompany om;
private Database db;
private DbCommand cmd;
private DbConnection con;
public void AddNDADetails(string id)
{
try
{
con = db.CreateConnection();
con.Open();
string query = string.Format("INSERT INTO NDAInformation (NDAID,RegNumber,DateCreate,RefName,ReqServ,ServDetails) VALUES (:ndaID,:regnumber,TO_DATE(:date,'DDMMYYYY'),:refname,:regserv,:servdetails)");
cmd = db.GetSqlStringCommand(query);
cmd = con.CreateCommand();
cmd.CommandText = query;
db.ExecuteNonQuery(cmd);
db.AddInParameter(cmd, "ndaID", DbType.String, id);
db.AddInParameter(cmd, "regnumber", DbType.String, om.RegNumber);
db.AddInParameter(cmd, "date", DbType.Date, om.Date);
db.AddInParameter(cmd, "refname", DbType.String, om.ComRef);
db.AddInParameter(cmd, "regserv", DbType.String, om.ComService);
db.AddInParameter(cmd, "servdetails", DbType.String, string.Join(",", om.ReqServiceDetails));
}
catch (Exception ex)
{
throw ex;
}
}
}
ORA-01745: invalid host/bind variable name
Cause: A colon in a bind variable or INTO specification was followed by an inappropriate name, perhaps a reserved word.
Action: Change the variable name and retry the operation.
=============================================================
Eg::.
Dim nCount As Integer
sSQL = "SELECT COUNT(*) FROM USERS WHERE USER_ID = :UID"
OracleConnection conn = new OracleConnection(ConfigurationSettings.AppSettings("connString"));
conn.Open();
OracleCommand cmd = new OracleCommand(sSQL, conn);
cmd.CommandType = CommandType.Text;
cmd.Parameters.Add("UID", OracleType.VarChar).Value = txtUserID.Text;
nCount = cmd.ExecuteScalar();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With