Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Since you are asking about Visual Studio (.NET), you need to use parameterized query. Don't use concatenation when constructing query</p> <pre><code>private void PrepareExample() { string s = Console.ReadLine(); MySqlCommand cmd = new MySqlCommand("INSERT INTO movie(title) VALUES (?title)", myConnection); cmd.Parameters.AddWithValue( "?title", "baby's world" ); cmd.Prepare(); cmd.ExecuteNonQuery(); } </code></pre> <p>Or</p> <pre><code>private void PrepareExample() { MySqlCommand cmd = new MySqlCommand("INSERT INTO movie(title) VALUES (?title)", myConnection); // try to input: baby's world. or try: baby"s world. everything are ok :-) cmd.Parameters.AddWithValue( "?title", Console.ReadLine() ); cmd.Prepare(); cmd.ExecuteNonQuery(); } </code></pre> <p>Though this is not exactly concatenation, don't use this:</p> <pre><code>qry = string.Format("INSERT INTO movie(title) VALUES("{0}", Console.ReadLine()); </code></pre> <p>Though if you really found a need to run SQL that way, replace single quote with backslash</p> <pre><code>qry = string.Format("INSERT INTO movie(title) VALUES("{0}", Console.ReadLine().Replace("'", "\'"); </code></pre> <p>But do consider using parameterized query instead of concatenation or string.Format, as parameterized query automatically take care of those delimeter nuances.</p> <p><a href="http://dev.mysql.com/doc/refman/5.0/es/connector-net-examples-mysqlcommand.html" rel="nofollow">http://dev.mysql.com/doc/refman/5.0/es/connector-net-examples-mysqlcommand.html</a></p>
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      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