使用ado.net操作文件 [英] manipulating files with ado.net

查看:41
本文介绍了使用ado.net操作文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网页,可以将csv文件批量插入到数据库中,但我希望能够在上传之前查看该文件,以确保其格式正确。我正在寻找的一些东西是


正确的电话号码格式(如果它没有区号,需要给它一个......这将是所有这些都是用512区域代码完成的)

正确的数据库字段数。现在只有


ID

患者姓名

医生姓名

预约时间

预约日期

当前时间

结果


ID,当前时间和结果均由数据库或程序我在后台运行,所以不必以任何方式操纵它们。


最后日期时间的格式为yyyymmdd:hhmm

我将需要所有传入的数据来符合这一点。


我知道可以用ado.net读取数据,但这对我来说是新的。有没有人知道最好的方法是什么?


谢谢


Doug


这是我的页面代码:

I have a web page that does a bulk insert of a csv file to a database but I want to be able to look at the file before it''s uploaded to make sure its in the proper format. A few of the things that I''m looking for are

Correct phone number format (if it doesnt have an area code, one needs to be given to it ... this will all be done with a 512 area code)
Correct number of fields for the database. Right now there are only

ID
Patient Name
Doctors Name
Appointment Time
Appointment Date
Current Time
Result

ID, Current Time and Result are all supplied either by the database or the program I''m running in the background so they don''t have to be manipulated in any way.

And finally the datetime is formatted as yyyymmdd:hhmm
and I will need all incoming data to comply with that.

I know that data can be read with ado.net but this is new to me. Does any one have any kind of idea as to what would be the best way to go about this?

Thank you

Doug

Here is my code for the page:

展开 | 选择 | Wrap | 行号

推荐答案

我不确定哪个部分你需要帮助。如果它是通过ADO.NET读取文件,那么你会做类似的事情:

I''m not sure which part you need help with exactly. If it is reading the file via ADO.NET then you would do something like:

展开 | 选择 | Wrap | 行号


Christoper,


使用ado.net从文件中获取信息对我来说是新的,所以我真的不知道如何读取数据,然后操纵它以匹配预设格式(如我所述)在我的另一篇文章中。)所以任何关于你如何最好地操纵数据的建议都是有用的。


谢谢


Doug
Christoper,

Using ado.net to get information from a file is new to me so I really have no idea how to read the data and then manipulate it to match a preset format (as I described in my other post.) So any suggestion that you may have on how best to manipulate the data as I''m reading it would be useful.

Thank you

Doug


你好D. oug,


我展示的代码将提供一个数据表。您可以迭代行和列以检查值。我不能更具体,因为我不知道你想如何处理一切。如果您发现错误或者您可能想要完全跳过该行,您可能需要使用默认值 - 我不知道。


以下是您可以迭代的方法:

Hi Doug,

The code I showed will give a data table. You can iterate the rows and columns to check the values. I cannot be more specific because I do not know how you want to handle everything. You may want to use a default value if you find an error or you may want to skip the row entirely - I don''t know.

Here is how you can iterate:

展开 | 选择 | Wrap | 行号


这篇关于使用ado.net操作文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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