Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query question

Status
Not open for further replies.

cyexpert

Programmer
Jun 16, 2002
40
CY
Maybe it will seems a bit stupid but i have to ask it :)

i gave a query:
string sqlString = "SELECT ID,Title,Abstract,Body FROM Articles WHERE Title LIKE '" + searchstring +"' ";

//Title example: How are you today

if i search with the keyword how it produces a table but in the title cell i only see the "How" and not all the title.

if i search with this query
string sqlString = "SELECT ID,Title,Abstract,Body FROM Articles WHERE Title LIKE '" + %searchstring +"' ";

it doesnt like that % why?

Thank you in advanced
 
What database are you using? Access uses a non-standard Asterisk character (*) for it's wildcard.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Yes i m using access. i tryed with an * instead of % and i get the followin error CS0193: The * or -> operator must be applied to a pointer
 
Chiph is right about wildcard (*).
I assume you type the whole select in an edit box:
SELECT ID,Title,Abstract,Body FROM Articles WHERE Title LIKE '*how*'"
Then here is the syntax:
string sqlString =m_lstBox1.Text.ToString().Trim();
//Use sqlString to Fill the DataTable.

For SQL type in the edit box:
SELECT ID,Title,Abstract,Body FROM Articles WHERE Title LIKE '%how%'"

If you have an edit box for the keyword then you should build the sqlString variable like here:
string sqlString="SELECT ID,Title,Abstract,Body FROM Articles WHERE Title LIKE '*" + searchstring.ToString().Trim() + "*'";

That is working but it is not a recommended solution.
-obislavu-




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top