M Mostez Well-Known Member Licensed User Longtime User Aug 17, 2020 #1 I use JdbcResultSet to read data from SQL database, I'm making a search dialog box to filter data, i want to add quotes to search-criteria according to its type like B4X: Copy if field.type = text then strSearch = ("'" & value & "'" ) else strSearch = (value) end if I tried IsNumber function, but when searching for phone number(text field) it returns true, so i can not add quotes in this case!! I think about adding check box to let user select if this Value is real number like unit-price, or if it is text, like phone-number! any ideas how solve this problem?
I use JdbcResultSet to read data from SQL database, I'm making a search dialog box to filter data, i want to add quotes to search-criteria according to its type like B4X: Copy if field.type = text then strSearch = ("'" & value & "'" ) else strSearch = (value) end if I tried IsNumber function, but when searching for phone number(text field) it returns true, so i can not add quotes in this case!! I think about adding check box to let user select if this Value is real number like unit-price, or if it is text, like phone-number! any ideas how solve this problem?
aeric Expert Licensed User Longtime User Aug 17, 2020 #2 Consider to use SQL prepared statement. You don’t need to worry about the quotes. Upvote 0
M Mostez Well-Known Member Licensed User Longtime User Aug 17, 2020 #3 Ok, i tried to put the quotes in both cases, i think it works , thanks Upvote 0
M Mahares Expert Licensed User Longtime User Aug 17, 2020 #4 Mostez said: i tried to put the quotes in both cases, i think it works , Click to expand... If you want to preserve the double quotes as part of the string, always use Smart Strings. Here it is: Code: Copy Dim value As String = "Mostez" Dim strSearch As String= $""${value}""$ Log(strSearch) 'displays: "Mostez" I hope this is in line with what you are trying to achieve. If not, ditch. Upvote 0
Mostez said: i tried to put the quotes in both cases, i think it works , Click to expand... If you want to preserve the double quotes as part of the string, always use Smart Strings. Here it is: Code: Copy Dim value As String = "Mostez" Dim strSearch As String= $""${value}""$ Log(strSearch) 'displays: "Mostez" I hope this is in line with what you are trying to achieve. If not, ditch.