将平面txt文件插入到SQL Server表中 [英] Insert a flat txt file into a SQL server table

查看:105
本文介绍了将平面txt文件插入到SQL Server表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用C#将平面文本文件插入SQL Server表中.

SQL表有4列.

文本文件行长27个字符,应该分成4列.

第一列是6个字符,2-1个字符,3-8个字符和4-6个字符

如何获取文本文件并将其插入到SQL Server表中

I need to insert a flat text file into a SQL Server table using C#.

The SQL table has 4 columns.

The text file line is 27 characters long and it should break up into the 4 columns.

The 1st column is 6 characters, 2nd - 1 character, 3rd - 8 characters and 4th - 6 characters

How do I get to read the text file and insert it into a SQL Server table

推荐答案

请参见 ^ ]文章.它显示了读取固定宽度的平面文件的方法.在对象中拥有文件数据后,就可以构建一个插入命令并在数据库中进行插入.
See this[^] article. It shows way to read fixed width flat file. Once you have the file data in your object, you can build up an insert command and do the insert in your database.


尝试一下,

http://webnetrevolution.blogspot.com/2011/02/reading-flat- file-in-vbnet.html [ ^ ]
Try this,

http://webnetrevolution.blogspot.com/2011/02/reading-flat-file-in-vbnet.html[^]


这篇关于将平面txt文件插入到SQL Server表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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