,
Share this with your friends 
 

BULK INSERT FROM CSV FILE

0 ratings Views 602 
Author: Daniel_7464bf92 (Daniel Odongo)  View Profile |  View other solutions by this author

Question / Problem


Insert all rows in a csv file to a table in a database specifying which start with

Solution

dim con as new sql connection(<insert connection string>)
dim cmd as new sql command
dim filename as string="<insert file location>"

If file.exists(filename) Then
Try
con.open
cmd=new sql command("bulk insert <insert table_name> from '"+filename+"' with (firstrow=3,fieldterminatoor=",",rowterminator="\n")",con)
cmd.executenonquery()
con.close

catch
msgbox(ex.message)
End try

else
msgbox("No upload file exists",mysgboxstyle.information)
End If


Applies to

VB 2005 ,Microsoft SQL Server 2008

Rank It

Login to rank it

Report


Advertisement