problems with sqlps-commands

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Don Jones Don Jones 2 years, 1 month ago.

  • Author
    Posts
  • #20143
    Profile photo of Axel Schmidt
    Axel Schmidt
    Participant

    Hi,
    I have a Problem running some SQL-commands with powershell:

    $Command.CommandText = "Insert into [smartPN_Config].[dbo].[Text] (textid,languageid, textclass,
    text, longtext,informadministrator) values
    ('ERROR_1000','DE','error','Fehler beim Empfang einer Nachricht von Unit \"{smartUnitId}\" (RemoteEndpoint:{RemoteEndpoint})',
    'Beim Empfang einer Nachricht von der smartUnit \"{smartUnitId}\" (RemoteEndpoint=\"{RemoteEndpoint})\" wurde eine unerwartete Exception Type=\"{ExceptionType}\" mit der Nachricht \"{ExceptionMessage}\"empfangen. ','1');"
    $Command.ExecuteNonQuery()

    He complains as Parser error for the { and } in the data of the SQL-command.
    Taking of the brackets – no Problems.
    The SQL-commands in the Management Studio work fine.
    Any ideas?
    Thanks!

  • #20181
    Profile photo of Don Jones
    Don Jones
    Keymaster

    So, to be clear, these aren't SQL commands, they're the .NET SqlClient classes. Bit different.

    It would help if you could post the specific error message, especially if you can do so from an English language version of PowerShell. But, at a guess, curly brackets are reserved characters for PowerShell and it's probably trying to interpret what's inside them as code.

You must be logged in to reply to this topic.