0

My string is <br/>

var lookfor = "\(Dos LIKE ''" + Dos + "'' OR Practice LIKE ''" + PracticeName + "''  OR Patient LIKE ''" + PatientName + "''  OR ClaimId LIKE ''" + ClaimId + "'' OR Charges LIKE ''" + Charges + "'' OR Payment  LIKE ''" + Payment + "'' OR InsuranceStatus  LIKE ''" + Status + "'')";

but i required a string <br/>

var lookfor = '\(Dos LIKE ''" + Dos + "'' OR Practice LIKE ''" + PracticeName + "''  OR Patient LIKE ''" + PatientName + "''  OR ClaimId LIKE ''" + ClaimId + "'' OR Charges LIKE ''" + Charges + "'' OR Payment  LIKE ''" + Payment + "'' OR InsuranceStatus  LIKE ''" + Status + "'')';

I am try this code but cannot resolved it

var jsonStr = lookfor.replace(/"/g, "'");
var jsonStr1= lookfor.replace(/"/g, '\'');

please help....

Barr J
  • 10,636
  • 1
  • 28
  • 46
  • 5
    Possible duplicate of [What are good ways to prevent SQL injection?](https://stackoverflow.com/questions/14376473/what-are-good-ways-to-prevent-sql-injection) – mjwills Aug 09 '18 at 05:24
  • 2
    Do not replace them - use sql parameters. – Basin Aug 09 '18 at 05:24
  • 1
    "but i required a string
    " , what does that mean? Are you looking for values that contain a ´
    ´ ? Do you think your ´lookfor´ variable needs to have a break in it? ...?
    – AsheraH Aug 09 '18 at 06:12

2 Answers2

0
var lookfor = "\\(Dos LIKE ''" + Dos + "'' OR Practice LIKE ''" + PracticeName + "''  OR Patient LIKE ''" + PatientName + "''  OR ClaimId LIKE ''" + ClaimId + "'' OR Charges LIKE ''" + Charges + "'' OR Payment  LIKE ''" + Payment + "'' OR InsuranceStatus  LIKE ''" + Status + "'')";
var newTemp = lookfor.Replace("\"", "'");

Here is a demo on ideone

Gauravsa
  • 6,330
  • 2
  • 21
  • 30
-1

var jsonStr = lookfor.replace(@"""", @"\""");

Heena
  • 1
  • 1