Your question, your audience. Choose who sees your identity—and your question—with question security.
If File.Exists(sHospDataFile) Then
Try
conn.Open()
' ------ Load the data from the .CSV file: ----------
Dim strSQL As String
strSQL = "Select * " & _
" INTO HospitalInvoice.dbo.[Hospital Billing Data SQL] " & _
"FROM OPENROWSET('MSDASQL','Driver={Microsoft Text Driver (*.txt; *.csv)}; DEFAULTDIR=C:\Data\; Extensions=csv; HDR=No;','SELECT * FROM HospitalInvoicesData.csv') "
Dim objCommand As SqlClient.SqlCommand
objCommand = New SqlClient.SqlCommand(strSQL, conn)
objCommand.CommandText = strSQL
objCommand.ExecuteNonQuery()
conn.Close()
Catch ex As Exception
sResultText = sResultText & "<BR>" & ex.Message
MsgBox(sResultText)
End Try
End If
If File.Exists(sHospDataFile) Then
Try
conn.Open()
' ------ Load the data from the .CSV file: ----------
Dim strSQL As String
strSQL = "Select * " & _
" INTO HospitalInvoice.dbo.[Hospital Billing Data SQL] " & _
"FROM OPENROWSET('MSDASQL','Driver={Microsoft Text Driver (*.txt; *.csv)}; DEFAULTDIR=\\cimadhoc\Data Sources\hospitalinvoicesdata.csv; Extensions=csv; HDR=No;','SELECT * FROM HospitalInvoicesData.csv') "
Dim objCommand As SqlClient.SqlCommand
objCommand = New SqlClient.SqlCommand(strSQL, conn)
objCommand.CommandText = strSQL
objCommand.ExecuteNonQuery()
conn.Close()
Catch ex As Exception
sResultText = sResultText & "<BR>" & ex.Message
MsgBox(sResultText)
End Try
End If
ALTER PROCEDURE dbo.InsertHospitalData
as
begin
BULK INSERT [Hospital Billing Data SQL]
FROM '\\Cimadhoc\Data Sources\HospitalInvoicesData.csv'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
END
System.IO.File.Move('C:\myFolder\myFile.csv', '\\myNetworkPlace\myFileCopy.csv')
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
http://www.daniweb.com/software-development/vbnet/threads/52051