Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Visual-Studio
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 11:50am
Comments
ryanb31 at 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'.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

You can try...
 
string keyword = textbox.Text;
var substring = keyword.Split('/');
 
var dbSaveString = substring[substring.Length - 1];
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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  
v2
Comments
Mathlab at 14-Nov-12 17:39pm
   
You can do it using LINQ but its a little long
Christian Graus at 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 :-)

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

  Print Answers RSS
0 OriginalGriff 400
1 Jochen Arndt 190
2 Richard MacCutchan 135
3 DamithSL 95
4 Garth J Lancaster 90
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,032
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,220


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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100