如何搜索ID号的最后一位数字的记录 [英] how to search record with last digits of ID number

查看:84
本文介绍了如何搜索ID号的最后一位数字的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有条码41/3/100,

当我使用扫描仪扫描条形码时,数据库中将保存100个,当我单击按钮时,它将读取41/3/100的信息我应该如何仅使用c#代码在100个记录中搜索记录??

help

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

推荐答案

您可以尝试...

You can try...

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

var dbSaveString = substring[substring.Length - 1];


ryan是正确的,如果它是字符串,则可以使用LIKE子句.如果是数字,则必须编写将其转换为字符串的SQL,以便可以使用LIKE子句(假定可行).否则,您将陷入困境.一种可能性是,如果您搜索351,则可以在其中x%1000 = 351的情况下进行操作.也就是说,如果将x除以1000,则余数为351.因此,如果您要搜索两位数的数字,则应为%100,依此类推.

再次查看之后,您显然正在存储一个字符串,因此需要搜索x像%100".
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.


在我的进程中,我正在使用sql server 2008 r2和41/3/是固定的,值100会递增,只有100会保存在数据库中
就像
100
101
102
103等

但对于条形码,它将得到
41/3/100
41/3/101
41/3/102
等等...


当他们使用条形码扫描仪41/3/102或文本框中的某些内容单击搜索按钮进行扫描时,我应该如何仅使用102 ???/
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 ???/


这篇关于如何搜索ID号的最后一位数字的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆