如何使用vb.net保存到mssql中时验证.txt文件中的数据 [英] How to Validate data in .txt file while saving into mssql using vb.net

查看:60
本文介绍了如何使用vb.net保存到mssql中时验证.txt文件中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的.txt文件包含:



SoldQTY,SoldAmt,RegTqty,MdtQty,RegBqty,MdBqty,RegTinv,MdTinv,RegBinv,MdBinv,DR1,DR1qty,DR2 ,DR2qty



24,13697,10,5,4,5,805,710,571,491,0,0,0,0



我已经将它保存在数据库中,

问题是,如何替换字符,例如代替0,他们键入字母o ..

我想在将数据上传到数据库时设置此数据验证..



请帮帮我们.. Thx

My .txt file contains:

SoldQTY, SoldAmt, RegTqty, MdtQty, RegBqty, MdBqty, RegTinv, MdTinv, RegBinv, MdBinv, DR1, DR1qty, DR2, DR2qty

24, 13697, 10, 5, 4, 5, 805, 710, 571, 491, 0, 0, 0, 0

I've already saved it in the database,
The problem is, how to replace characters like for example instead of 0 they typed letter o..
I want to set this data validation while uploading it to database..

Please Help me guys.. Thx

推荐答案

如果您知道它应该是一个整数,您可以使用int.TryParse方法来查看是否可以从文本字段中解析整数。如果它是一个不同的类型,大多数原子数字类型都有一个TryParse方法做同样的事情。



你也可以遍历所有字符并检查它们是否是所有数字。
If you know its supposed to be an integer, you can use the int.TryParse methods to see if you can parse an integer from the text field. If its a different type most of the atomic numeric types have a TryParse method that does the same thing.

You could also loop through all the characters and check that they are all numeric.


这篇关于如何使用vb.net保存到mssql中时验证.txt文件中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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