开发者

VB ADO.NET Textbox input validation against MSSQL DB

I have one textbox basically the user is going to enter in a 9 digit number or letters. From there I want to have a buttonclick event that validates this against 2 columns in a MSSQL Database. First to check if the number exists, next to check if it is active or inactive.

There are about 27000 rows of numbers so my main question is what is the best approach to handling something like this.

  • Should I create a view and validate in the click event.
  • Should I create a stored procedur开发者_开发知识库e in sql that takes an input parameter and call it in the click event.

I was also reading about storing the information in a dataset however with that many records i am assuming that is going to be a slow process.

If none of these approaches are right I would appreciate the correct way to go about doing this and maybe a few links that can get me started. I searched but most people are using a dataset and if that is not going to affect my performance I will more than happy to approach it that way just not too sure.

Thanks


Stored Procedures and Views should work the same as long as you have a where clause that filters down to exactly the data you want, rather than (in the case of the view) returning all rows from the view and then filtering in memory. It would need to look like this:

Select Number, Activer from ViewName where number = (your number)

or

EXEC spValidateNumber @Number = (your number)

As for when to do your validation, if this procedure takes more than, say, one second, you should probably have the user ask for validation by clicking a button, so that they anticipate the delay. If it runs on the textbox's lostfocus event, it should run without any noticable delay for the user.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜