Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. BindingSource.Filter problem

BindingSource.Filter problem

Scheduled Pinned Locked Moved C#
help
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Seishin
    wrote on last edited by
    #1

    Hi! my problem is that i try to input string containing ' char into filter statement which causes an System.Data.SyntaxErrorException is thrown.. string str1 = "aaaa"; string str1 = "aa'aa"; bs.Filter = string.Format("val1 like '{1}' and val2 like '{2}'", str1, str2); outcome would be: bs.Filter = "val1 like 'aaaa' and val2 like 'aa'aa'"; thanks for any help!!!

    life is study!!!

    A 1 Reply Last reply
    0
    • S Seishin

      Hi! my problem is that i try to input string containing ' char into filter statement which causes an System.Data.SyntaxErrorException is thrown.. string str1 = "aaaa"; string str1 = "aa'aa"; bs.Filter = string.Format("val1 like '{1}' and val2 like '{2}'", str1, str2); outcome would be: bs.Filter = "val1 like 'aaaa' and val2 like 'aa'aa'"; thanks for any help!!!

      life is study!!!

      A Offline
      A Offline
      Anil Ch
      wrote on last edited by
      #2

      1. string.Format("val1 like '{1}' and val2 like '{2}'", str1, str2); Should be string.Format("val1 like '{0}' and val2 like '{1}'", str1, str2); 2. aa'aa should be aa''aa becuase filter behaves same way as a stored procedure would behave.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups