Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi there,


C#
da = new SqlDataAdapter("SELECT * FROM QuestionBank where std='" + DropDownList1.SelectedItem.Text + "' and subject='" + DropDownList2.SelectedItem.Text + "' and chapter='" + Textbox1.Text + "'", cn);


in textbox1.text it would be data in gujarati or hindi. i can't search data.

i used nvarchar for chapter column.


Thanks.
Posted
Comments
Suvendu Shekhar Giri 26-Jun-15 23:44pm    
I don't see any problem in the query, only thing you may want to try is instead of using equals to operator try LIKE operator like
chapter LIKE '%" +Textbox1.Text+"%'"
N:B: It is of no use if you want every bit to match.
Member 11422010 27-Jun-15 1:22am    
not working

1 solution

No, it's not Hindi. You should understand that Hindi is not script (not writing system, not alphabet), it is a language. The alphabet is Devanāgarī, देवनागरी. It was formerly used for Gujarati, but presently a separate Gujarati script (ગુજરાતી લિપિ Gujǎrātī Lipi) is used.

Please see:
https://en.wikipedia.org/wiki/Devanagari[^],
https://en.wikipedia.org/wiki/Gujarati_language#Writing_system[^],
https://en.wikipedia.org/wiki/Gujarati_alphabet[^].

You just need to use Unicode data types. I have no idea what you are missing. You could fail to search for something by a number of different reasons.
As to your query, your approach is wrong from the very beginning. The query composed by concatenation with strings taken from UI. Not only repeated string concatenation is inefficient (because strings are immutable; do I have to explain why it makes repeated concatenation bad?), but there is way more important issue: it opens the doors to a well-known exploit called SQL injection.

This is how it works: http://xkcd.com/327.

Are you getting the idea? The string taken from a control can be anything, including… a fragment of SQL code.

What to do? Just read about this problem and the main remedy: parametrized statements: http://en.wikipedia.org/wiki/SQL_injection.

With ADO.NET, use this: http://msdn.microsoft.com/en-us/library/ff648339.aspx.

Please see my past answers for some more detail:
EROR IN UPATE in com.ExecuteNonQuery();,
hi name is not displaying in name?.

Now, please listen carefully. I have never being in India and cannot speak any of the language. You are from India. But I have a lot of respect to great Indian culture, as well as other cultures, enough to avoid being ignorant so much to mix up languages with writing systems and to be so lazy not to read about the cultures involved. How come you, a software developer from India, can be so ignorant or lazy to have no clue of such basic cultural things? You are not along. I cannot solve this mystery. This is too bad and sad…

—SA
 
Share this answer
 
v2

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