Note that there are some explanatory texts on larger screens.

plurals
  1. POWorking with ADO.net and special characters in SQL
    primarykey
    data
    text
    <p>I want to write a small application in Winforms, where I will be able to write some words and write them to a SQL database using ADO.net.</p> <p>I'm having trouble when I want to write a string with a placeholder like:</p> <pre><code>Give me your '%s' right now! </code></pre> <p>What is recorded in my DB is:</p> <pre><code>Give me your **"%s"** right now! </code></pre> <p>How can I overcome this be changing the string via C# that is transferred to my DB?</p> <p>This is part of my code:</p> <pre><code> public virtual int Split(global::System.Nullable&lt;int&gt; ID, object SplitXMLDoc, string CreatedBy) { global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[4]; if ((ID.HasValue == true)) { command.Parameters[1].Value = ((int)(ID.Value)); } else { command.Parameters[1].Value = global::System.DBNull.Value; } if ((SplitXMLDoc == null)) { command.Parameters[2].Value = global::System.DBNull.Value; } else { command.Parameters[2].Value = ((object)(SplitXMLDoc)); } if ((CreatedBy == null)) { command.Parameters[3].Value = global::System.DBNull.Value; } else { command.Parameters[3].Value = ((string)(CreatedBy)); } global::System.Data.ConnectionState previousConnectionState = command.Connection.State; if (((command.Connection.State &amp; global::System.Data.ConnectionState.Open) != global::System.Data.ConnectionState.Open)) { command.Connection.Open(); } int returnValue; try { returnValue = command.ExecuteNonQuery(); } finally { if ((previousConnectionState == global::System.Data.ConnectionState.Closed)) { command.Connection.Close(); } } return returnValue; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload