Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- INSERT INTO PERSON (ID, NAME, BIRTHDATE) VALUES (:id, :name, :birthdate)
- INSERT INTO PERSON (ID, NAME, BIRTHDATE) VALUES (23, ‘Mike’, TO_DATE('2003/07/09', 'yyyy/mm/dd')
- INSERT INTO PERSON (ID, NAME, BIRTHDATE) VALUES (:id, :name, :birthdate) [:id=23, :name=Mike, birthdate=2004/07/09 00:00:00]
- using (OracleConnection connection = new OracleConnection(connectionString))
- using (OracleCommand command = new OracleCommand(statement, connection))
- {
- command.Parameters.AddWithValue(":id", id);
- command.Parameters.AddWithValue(":name", name);
- command.Parameters.AddWithValue(":birthdate", birthdate);
- command.Connection.Open();
- log.DebugFormat("Executing statement: {0}.", command.CommandText);
- // there I would add some more code to iterate over
- // the parameters and print them out
- command.ExecuteNonQuery();
- command.Connection.Close();
- }
- protected string GetCommandLogString(IDbCommand command)
- {
- string outputText;
- if (command.Parameters.Count == 0)
- {
- outputText = command.CommandText;
- }
- else
- {
- StringBuilder output = new StringBuilder();
- output.Append(command.CommandText);
- output.Append("; ");
- IDataParameter p;
- int count = command.Parameters.Count;
- for (int i = 0; i < count; i++)
- {
- p = (IDataParameter) command.Parameters[i];
- output.Append(string.Format("{0} = '{1}'", p.ParameterName, p.Value));
- if (i + 1 < count)
- {
- output.Append(", ");
- }
- }
- outputText = output.ToString();
- }
- return outputText;
- }
- INSERT INTO PERSON (ID, NAME, BIRTHDATE)
- VALUES ('"+id+"', '"+name+"', '"+birthdate+"')
Add Comment
Please, Sign In to add comment