Click here to Skip to main content
15,886,963 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
i have a barcode 41/3/100 ,

100 will be saved in data base when i scan barcode with scanner it will read 41/3/100 when i click the button how should i search the record only with 100 using c# code????

help
Posted
Comments
ZurdoDev 14-Nov-12 16:51pm    
I don't fully understand your question but if you want to find the data in SQL just use WHERE field LIKE '%100'.

You can try...

C#
string keyword = textbox.Text;
var substring = keyword.Split('/');

var dbSaveString = substring[substring.Length - 1];
 
Share this answer
 
ryan is right, if it's a string, you can use a LIKE clause. If it's a digit, you will have to write SQL that turns it in to a string so you can use a LIKE clause ( assuming that works ). Otherwise, you're stuck. One possibility, if you were searching for 351, you could do where x % 1000 = 351. That would be if you divide x by 1000, 351 is the remainder. so if you were searching for a two digit number, it would be % 100, etc.

Having looked again, you're clearly storing a string, so searching x LIKE '%100' is what you need.
 
Share this answer
 
v2
Comments
[no name] 14-Nov-12 17:39pm    
You can do it using LINQ but its a little long
Christian Graus 14-Nov-12 17:40pm    
Well, it's about the same, but as he's only got a string, all he needs is LIKE. Which is sad, I was kind of proud of my solution for digits :-)
in my process i am using sql server 2008 r2 and 41/3/ is fixed and the value 100 will increment and only from 100 will save in database
like
100
101
102
103 so on

but for the barcode it will get
41/3/100
41/3/101
41/3/102
so onn...


when they scan with barcode scanner 41/3/102 or some thing in text box when they click search button how should i search with only 102 ???/
 
Share this answer
 
Hi,

Use the below code snippet into your search method.

string keyword = textbox.Text.SubString(textbox.Text.IndexOf("41/3/"));

and use keyword in your where condition.

Hope this will help you.
 
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