Search code examples
c#databaseoracleoledboledbcommand

OleDB newLine character


I have problem with oleDB \n \r parsing.

I want to pass multi-line string to database. Query looks line this:

"{call merge_procedure(12345, 'Datum poskytnutí '||chr(13)||chr(10)||' dokumentace')}"
  • chr(13) => \r
  • chr(10) => \n

but command execution fails on

Unspecified error
  at System.Data.OleDb.OleDbCommand.ProcessResults(OleDbHResult hr)
  at System.Data.OleDb.OleDbCommand.InitializeCommand(CommandBehavior behavior, Boolean throwifnotsupported)
  at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
  at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
  at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()

What I've tried:

  • 'Datum poskytnutí \r\n dokumentace'
  • 'Datum poskytnutí ' + Enviroment.NewLine + ' dokumentace'
  • Changing single quotes to double

Could you please help me, how to pass multi-line string to database using oleDB?


Solution

  • As Wernfried Domscheit wrote in a comment, if I bond parameters it works.

    call merge_procedure(12345, {0})

    or in C#

    string.Format("call merge_procedure(12345, 'Datum poskytnutí {0} dokumentace'))", Environment.NewLine);