如何使用vb.net将csv文件导入数据库 [英] how to import csv file into the database using vb.net
本文介绍了如何使用vb.net将csv文件导入数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请帮助我
我想使用vb.net将test.csv导入数据库
首先,我将test.csv上传到文本框中
然后,我将单击提交"按钮以将其导入数据库sqlserver
我想将test.csv放入
包含名称,联系人的表名
我希望有人可以帮助我,因为这很紧急.
help me please
i want to import test.csv into database using vb.net
first i will upload test.csv into text box
and after that i will click "submit" button to import it into the database sqlserver
i want to put test.csv into
table name which contains name,contacts
i hope someone can help me because it is urgent
推荐答案
这看起来很可疑,很像作业.
因此,这是一种入门的方法(没有人会为此提供代码)
第1步:使用文本框创建表单(最好使用RichTextBox,因为它是多行的)
步骤2:在加载/显示/按钮单击事件中读取.csv文件(它只是一个文本文件,因此像读取任何其他文本文件一样读取它)
您可以为此使用几种方法(streamreader/my.computer.filesystem .../...)
步骤3:将其写入数据库(查看连接到数据库)
您将需要名称空间:system.data.sqlclient
调查:sqlconnection/sqlcommand/sqlparamater(非常重要)/sqltransaction/...
您还需要知道如何将阅读的文本拆分为相应的列. (通常会有一个字符指示新列的开始)
您将需要自己进行研究.
This looks suspiciously a lot like homework.
So here is a way to get you started (nobody will just give you the code for this)
Step 1 : create form with textbox (probably better to take a richtextbox since that''s multiline)
Step 2: read the .csv file (it''s just a text file so read it like any other text file) in the load / shown / button click event
You can use several methodes for this (streamreader / my.computer.filesystem... / ...)
Step 3: write it to the database (look into connecting to database)
You''ll need the namespace: system.data.sqlclient
look into: sqlconnection / sqlcommand / sqlparamater (very important) / sqltransaction / ...
You''ll also need to know how to split the text you''v read into the corresponding columns. (usually there is a character indicating the start of a new column)
You''ll have to the research on your own for this.
这不是一项作业.但是我只学习vb.net,只有两天时间,我需要非常快地学习,因为我有紧急事项
我已经完成了上传part.在那里,我单击了上传",然后将test.csv上传到了文本框中
问题是
我只需要提交"按钮即可工作.但似乎没有解决.单击提交时我想要它,它将把test.csv导入sql server中的sms_contact表.
菜鸟在这里.需要一个示例来学习
its not a homework.but i just learn vb.net only 2 days and i need to learn very fast because i have urgent matters
i have done the upload part.where i click upload and the test.csv were uploaded into the text box
the problem is
i just need "submit" button to work.but it seems didnt work out.i want it when i click submit, it will import the test.csv to sms_contact table in sql server
noob here.need an example to learn from
如果您需要一个示例,那么我建议您使用google.关于如何按照您的要求去做,有很多信息.
在这里,我为您完成了最困难的部分: http://tinyurl.com/26zoa5f [
If you need an example, then I suggest you use google. There is a wealth of information on how to do just what you are asking.
Here, I''ve done the hard part for you: http://tinyurl.com/26zoa5f[^]
这篇关于如何使用vb.net将csv文件导入数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文