Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to recognize & escape apostrophe in sql search
    primarykey
    data
    text
    <p>I have sql query in my C# program to search or filter some records. When I pass a string value with apostrope, it throws some incorrect key word error in my C# program.</p> <p><strong>My sample Input</strong></p> <pre><code>String Val= Tests of the 'convergence hypothesis' : a critical note / Daniel Cohen. </code></pre> <p><strong>My Query</strong></p> <pre><code>string MySqlQry="SELECT bc.BibId, stuff( (SELECT ' ' + bsc.NormValue + '' FROM BibContents bsc WHERE bsc.bibid = bc.bibid AND bsc.tagno = '245' ORDER BY bsc.Sfld FOR xml path(''), root('MyString'), TYPE).value('/MyString[1]','varchar(max)') , 1, 1, '') AS Title, stuff( (SELECT ' ' + bsc.NormValue + '' FROM BibContents bsc WHERE bsc.bibid = bc.bibid AND bsc.tagno = '020' ORDER BY bsc.Sfld FOR xml path(''), root('MyString'), TYPE).value('/MyString[1]','varchar(max)') , 1, 1, '') AS ISBN, stuff( (SELECT ' ' + bsc.NormValue + '' FROM BibContents bsc WHERE bsc.bibid = bc.bibid AND bsc.tagno = '250' ORDER BY bsc.Sfld FOR xml path(''), root('MyString'), TYPE).value('/MyString[1]','varchar(max)') , 1, 1, '') AS Edition, stuff( (SELECT ' ' + bsc.NormValue + '' FROM BibContents bsc WHERE bsc.bibid = bc.bibid AND bsc.tagno = '260' ORDER BY bsc.Sfld FOR xml path(''), root('MyString'), TYPE).value('/MyString[1]','varchar(max)') , 1, 1, '') AS Publisher, (SELECT top(1) Value FROM BibContents WHERE TagNo='100' AND Sfld='a' AND BibId=bc.BibId) AS Author FROM BibContents bc WHERE (bc.NormValue LIKE '" + Val + "%' OR bc.NormValue LIKE '% " + Val + "%') AND bc.TagNo='245'"; model = db.ExecuteStoreQuery&lt;PoDetails&gt;(MySqlQry).ToList(); </code></pre> <p>Any help in providing the solution is appreciated. </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.
 

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