By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,481 Members | 979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,481 IT Pros & Developers. It's quick & easy.

get csv from the web

P: n/a
hello!

i will need to write a client application that will download a csv
file from a http url like this http://www.web.com/file.csv

once the file is downloaded i will be importing it into a sql server
database table. how do i make a vb.net program download this file and
save it to my hard drive? or how do i make my vb.net program open the
file and read it from the internet. then maybe i could put it in a
datatable? how do i go about this?

AP!
Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi Antonio,

Once the file is downloaded, open it in vb .net using the oledb driver.
Then open the sql table using the sql client driver. Then loop through the
csv row by row and add new row to the sql table.

HTH,

Bernie Yaeger

"Antonio Policelli" <bl*****@yahoo.com> wrote in message
news:62**************************@posting.google.c om...
hello!

i will need to write a client application that will download a csv
file from a http url like this http://www.web.com/file.csv

once the file is downloaded i will be importing it into a sql server
database table. how do i make a vb.net program download this file and
save it to my hard drive? or how do i make my vb.net program open the
file and read it from the internet. then maybe i could put it in a
datatable? how do i go about this?

AP!

Nov 20 '05 #2

P: n/a
Here is another way.
What happens in the code is you open the flat file and fill the Dataset with
data. Once you have that all you do is upload command on the SQL
dataaddapter and you good to go. You need to use a schema.ini file do
defilne structure of your file.
http://authors.aspalliance.com/ericm...les/textdb.asp
http://msdn.microsoft.com/library/de...cjetsdk_98.asp
Its not that much code. I get 800 rows in to the DB in less then 1 sec.

Dim FilePath As String = "C:\ftproot\TOG\"

Dim Conn As New
System.Data.OleDb.OleDbConnection("Provider=Micros oft.Jet.OLEDB.4.0;Data
Source=" & FilePath & ";Extended Properties=""text;HDR=NO;FMT=Delimited""")

Dim Comm As New System.Data.OleDb.OleDbDataAdapter("select * from
c126927_1_sc_011504_001.txt", Conn)

Dim DS As New DataSet

Try

Comm.AcceptChangesDuringFill = False

Comm.Fill(DS)

DS.Tables(0).TableName = "scs_ds_sold_customer"

Dim objCn As New
SqlConnection("Server=NTCH27;Database=scs_auto_men u;Trusted_Connection=True;
")

Dim NwindDA As New SqlDataAdapter("select * from scs_ds_sold_customer",
objCn)

Dim x As SqlCommandBuilder = New SqlCommandBuilder(NwindDA)

objCn.Open()

NwindDA.Update(DS, "scs_ds_sold_customer")

Catch e As Exception

End Try



"Antonio Policelli" <bl*****@yahoo.com> wrote in message
news:62**************************@posting.google.c om...
hello!

i will need to write a client application that will download a csv
file from a http url like this http://www.web.com/file.csv

once the file is downloaded i will be importing it into a sql server
database table. how do i make a vb.net program download this file and
save it to my hard drive? or how do i make my vb.net program open the
file and read it from the internet. then maybe i could put it in a
datatable? how do i go about this?

AP!

Nov 20 '05 #3

P: n/a
thank you bernie and ruslan, can you tell me more about how to download the csv though? when i run this app, i will download 500 csv files each one at a time and upload the data. so i have to loop through each file. this will be doing once per week. i am very interested to find out how to download the csv from in vb.net code. thank you!

AP

----- Bernie Yaeger wrote: ----

Hi Antonio

Once the file is downloaded, open it in vb .net using the oledb driver
Then open the sql table using the sql client driver. Then loop through th
csv row by row and add new row to the sql table

HTH

Bernie Yaege

"Antonio Policelli" <bl*****@yahoo.com> wrote in messag
news:62**************************@posting.google.c om..
hello
i will need to write a client application that will download a cs

file from a http url like this http://www.web.com/file.cs
once the file is downloaded i will be importing it into a sql serve

database table. how do i make a vb.net program download this file an
save it to my hard drive? or how do i make my vb.net program open th
file and read it from the internet. then maybe i could put it in
datatable? how do i go about this
AP


Nov 20 '05 #4

P: n/a
* bl*****@yahoo.com (Antonio Policelli) scripsit:
i will need to write a client application that will download a csv
file from a http url like this http://www.web.com/file.csv


Have a look at 'WebClient.DownloadFile'.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.