SQL Database
-
how to match a string from a C# code to a sub-string of a field of a record in a SQL Database??
-
how to match a string from a C# code to a sub-string of a field of a record in a SQL Database??
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
-
how to match a string from a C# code to a sub-string of a field of a record in a SQL Database??
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();
-
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();
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...