Import csv file into excel programmatically

S

Saumin

hi,
I want to import a csv file into my excel template file programmatically in
a windows application. i am using vb.net, ado.net to do this. but i am
getting an error: Operation must use an updateable query. I have checked
security and it is fine. aspnet user has full permissions on both the files.
I will really appreciate a quick response. following is the code:
csvPath = "c:\"
strCSVConn = String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source={0};Extended Properties=""text;HDR=No;FMT=Delimited""", csvPath)

Dim objCSVConn As New OleDbConnection(strCSVConn)
objCSVConn.Open()
Dim objCmd As New OleDbCommand
objCmd.Connection = objCSVConn
Try
objCmd.CommandText = "Insert INTO [Sheet1$] IN 'C:\Book1.xls'
'Excel 8.0;' SELECT * FROM 261_WildOats_12292004_EE.csv"
objCmd.ExecuteNonQuery()
objCSVConn.Close()
Catch ex As Exception
If Not (objCSVConn Is Nothing) Then
objCSVConn.Close()
End If
MsgBox(ex.Message)
End Try

Thanks,
Saumin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top