J
Jim
I have an asp.net (vb) application in which users upload csv files to a
SQL Server 2000 database.
I've been using SQL Server DTS and stored procs to do this however I'd
like the solution to be a bit more flexible.
I've developed code to pull the csv file into a dataset using
oledbConnection/oledbCommand/oledbDataAdapter however I am unsure how
to insert the data into an existing SQL server table.
So, I've got....
Dim strFileName As String = "MyFile.csv"
Dim strPath As String = "C:\"
Dim strCon As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" + strPath + ";Extended
Properties='text;HDR=Yes;FMT=Delimited'"
Dim con As New OleDbConnection(strCon)
Dim cmdGetCsv As New OleDbCommand("SELECT * from " +
strFileName, con)
Dim csvAdapter As New OleDbDataAdapter(cmdGetCsv)
'Dim csvReader As OleDbDataReader
con.Open()
Dim dsCsv As DataSet = New DataSet
csvAdapter.Fill(dsCsv)
....
Clearly I now need to make a connection to my SQL db but how do I
insert all the records from the dataset?
The csv file could contain thousands of records. Are there performance
issues that would dictate one method over another?
Thanks in advance for any assistance.
SQL Server 2000 database.
I've been using SQL Server DTS and stored procs to do this however I'd
like the solution to be a bit more flexible.
I've developed code to pull the csv file into a dataset using
oledbConnection/oledbCommand/oledbDataAdapter however I am unsure how
to insert the data into an existing SQL server table.
So, I've got....
Dim strFileName As String = "MyFile.csv"
Dim strPath As String = "C:\"
Dim strCon As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" + strPath + ";Extended
Properties='text;HDR=Yes;FMT=Delimited'"
Dim con As New OleDbConnection(strCon)
Dim cmdGetCsv As New OleDbCommand("SELECT * from " +
strFileName, con)
Dim csvAdapter As New OleDbDataAdapter(cmdGetCsv)
'Dim csvReader As OleDbDataReader
con.Open()
Dim dsCsv As DataSet = New DataSet
csvAdapter.Fill(dsCsv)
....
Clearly I now need to make a connection to my SQL db but how do I
insert all the records from the dataset?
The csv file could contain thousands of records. Are there performance
issues that would dictate one method over another?
Thanks in advance for any assistance.