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. SQL Database

SQL Database

Scheduled Pinned Locked Moved C#
databasecsharpregextutorialquestion
4 Posts 3 Posters 1 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.
  • A Offline
    A Offline
    ankit_mait
    wrote on last edited by
    #1

    how to match a string from a C# code to a sub-string of a field of a record in a SQL Database??

    P C 2 Replies Last reply
    0
    • A ankit_mait

      how to match a string from a C# code to a sub-string of a field of a record in a SQL Database??

      P Offline
      P Offline
      Paul Conrad
      wrote on last edited by
      #2

      Many different ways you can go abouts doing this. SQL Substring Function[^] may help guide your way :)

      "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

      1 Reply Last reply
      0
      • A ankit_mait

        how to match a string from a C# code to a sub-string of a field of a record in a SQL Database??

        C Offline
        C Offline
        Cfer83
        wrote on last edited by
        #3

        i think you're looking to use the "LIKE" clause of SQL. In your SQL statement you'll be doing something like this: string myStr = "world"; string sSQL = "SELECT field from table where field LIKE @mystr;"; dbcommand.parameters.addwithvalue("@mystr",myStr); string mydbvalue = dbcommand.executescalar();

        A 1 Reply Last reply
        0
        • C Cfer83

          i think you're looking to use the "LIKE" clause of SQL. In your SQL statement you'll be doing something like this: string myStr = "world"; string sSQL = "SELECT field from table where field LIKE @mystr;"; dbcommand.parameters.addwithvalue("@mystr",myStr); string mydbvalue = dbcommand.executescalar();

          A Offline
          A Offline
          ankit_mait
          wrote on last edited by
          #4

          What would "LIKE" return in this condition: String to be found:"????2805" and string that is checked is "2805-2705" it will still find the sub-string but this is not what we were looking for.... wont it...

          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