Hi All,
I have to import a csv file to sql database.I searched on the net and found plenty of exampls but all with msaccess database.I did not find any example with
sql server.Can anybody have the code or the link?here is one example with msaccess
Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\;Extended Properties=""Text;HDR=No;FMT=Delimited""")
Dim da As New OleDbDataAdapter()
Dim ds As New DataSet()
Dim cd As New OleDbCommand("SELECT * FROM C:\Test.csv, cn)
cn.Open()
da.SelectCommand = cd
ds.Clear()
da.Fill(ds, "CSV")
dg.DataSource = ds.Tables(0)
cn.Close()
but when i am using the sqlserver how to get csv data by setting extended properties .
Regards
Brijesh Singh
Wy cant u try in sqlserver
bulk insert patientidx
from 'd:\IDX export1.csv'
WITH
(
FIELDTERMINATOR = ','
ROWTERMINATOR = '\n'
)
Here patientidx is the tablename
Thank u
Please remember to click "Mark as Answer" on this post if it helped you.
No comments:
Post a Comment