Click here to Skip to main content
Sign Up to vote bad
good
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 14-Nov-12 10:50am

Comments
ryanb31 - 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'.

4 solutions

You can try...
 
string keyword = textbox.Text;
var substring = keyword.Split('/');
 
var dbSaveString = substring[substring.Length - 1];
  Permalink  
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.
  Permalink  
Comments
Mathlab - 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 ???/
  Permalink  
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.
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 6,889
1 Prasad_Kulkarni 3,671
2 OriginalGriff 3,359
3 _Amy 3,312
4 CPallini 2,925


Advertise | Privacy | Mobile
Web01 | 2.6.130617.1 | Last Updated 19 Nov 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid