Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
In my application i have a search criteria field in which one document name field is there.
I have a document in my database with name $#%#$. Now, I want to search for document by entering only %.
How i do that?
I tried differnt things but its not working. If i entered % in the document name field it gives me all the document.But, I want only that document.
Thanks,
Umesh Tayade
Posted
Comments
[no name] 17-May-11 7:43am    
What have you tried for this, put your code we will guide you where you went wrong.
Member 4550493 17-May-11 8:07am    
queryBindValues.Add(CONST_VarDocName, %+ docName + %);

where if i entered the docname=% then it gives all record but i want only that record
Member 4550493 17-May-11 8:12am    
I tried following thing but it don't give any record return inputSQL.Replace("%", "''"); return inputSQL.Replace("%", "[%]"); return inputSQL.Replace("%", "%");
Member 4550493 17-May-11 8:26am    
orderSearchDetailViewModelConnector.ViewState.GetOrderSearchDetail( (txtDocName.Text != string.Empty) ? SafeSqlLiteral(txtDocName.Text.ToUpper().Trim()) : string.Empty);

private string SafeSqlLiteral(string inputSQL)
{
return inputSQL.Replace("\"", "''").Replace("&", "''").Replace("<", "''").Replace("%", "''");
}

if (!string.IsNullOrEmpty(docName))
{
query.ApplyPredicate(CONST_byDocName, CONST_target2);
queryBindValues.Add(CONST_VarDocName, CONST_PERCENTILE + docName + CONST_PERCENTILE);
}
This is my code
Please Reply Soon
Debojyoti Majumder 17-May-11 7:54am    
Please share your code.

1 solution

You may gain some better understanding from this page. In order to use a character defined as a wildcard in SQL, you would have to escape that character for it to be used as a literal in the query. The article I linked to explains how to do this.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900