Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Import csv file into excel programmatically

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;Da ta
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default Import csv file into excel programmatically


Saumin wrote:
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;Da ta
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



Saumin wrote:
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;Da ta
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


When using Text in the extended properties, the provider does not seem
to support the IN <database syntax. Try doing the other way round i.e.
use Excel 8.0 in the ADO connection string and Text in the IN clause.
Jamie.

--

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
import a many text files to excel programmatically sherry Excel Discussion (Misc queries) 16 September 25th 07 10:26 PM
Excel VBA - How do I programmatically change source code in another file? Lisa Norgaard Excel Programming 1 July 14th 04 04:09 PM
Import IE/WE Favorites programmatically R Avery Excel Programming 4 January 3rd 04 03:42 AM
Help with data importing from txt file to excel programmatically SUDHENDRA Excel Programming 2 December 7th 03 02:14 PM
programmatically close help file before Excel closes? RB Smissaert Excel Programming 2 July 21st 03 11:49 AM


All times are GMT +1. The time now is 07:30 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"