简体   繁体   English

如何使用不带掩码的电话号码从访问数据库中搜索数据

[英]How search data from access database using phone number that without masked

I have use this (123) 456-7890 format to search data on access database using winforms and my data was saved in same above format but I want do the search throw winform that allow me to enter 1234567890 then give the search result but I can't able to get it from access query 我已经使用(123)456-7890格式在使用winforms的访问数据库中搜索数据,并且我的数据以上述相同格式保存,但是我想进行搜索抛出winform,以允许我输入1234567890,然后给出搜索结果,但是我可以无法从访问查询中获取

I have tried remove using access format function on my database but it doesn't work and also I have tried mysql replace query still not working. 我已经尝试在数据库上使用访问格式功能删除,但是它不起作用,而且我尝试了mysql replace query仍然不起作用。

here is my select query 这是我的选择查询

Command.CommandText = @"SELECT * FROM PersonalINFO  WHERE (FirstName + ' ' + 
   LastName = '" + search_txt.Text + "') OR (EmailAddress = '" + 
   search_txt.Text + "') OR (Home_Tp = '" + search_txt.Text + 
   "') OR (Cell_Tp = '" + search_txt.Text + "') ";

How do I able to ignore the brackets and dashes in the phone number mask when searching I can't able to create new row that without mask because my data size over thousand I have tried remove using access format function on my database but it doesn't work. 搜索时如何忽略电话号码掩码中的方括号和破折号?我无法创建没有掩码的新行,因为我的数据大小超过一千,我曾尝试使用数据库上的访问格式功能删除该行,但它没有工作。

storing masked data is not good and it causes complexity hence logical errors and implementation difficulties. 存储被屏蔽的数据不是很好,并且会导致复杂性,从而导致逻辑错误和实现困难。 I suggest you to use plain format like 123456789 . 我建议您使用纯格式,例如123456789

we generally prefer to show masked data inside input field but store it as it is. 我们通常更喜欢在输入字段中显示被屏蔽的数据,但将其原样存储。


On the other hand using concatenated strings in query is very bad practice and it is vulnerable to SQL Injection attacks. 另一方面,在查询中使用串联字符串是非常糟糕的做法,并且容易受到SQL Injection攻击。 Instead you need to use Parameterized Queries 相反,您需要使用参数化查询

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM