Hi all
Am messing about with vb.net and Excel files in that i am trying to pull data from the excel file and insert data into the file. now i have managed to select the data in the .xls file, but i am running into some problems when i try to insert data into the file. Here is the code i use the insert data
While for the insert statement i am doing the following:
Any suggestions welcomed, not even sure if you can do an insert statement. Am working with a web project not a windows project.
Mike55
Am messing about with vb.net and Excel files in that i am trying to pull data from the excel file and insert data into the file. now i have managed to select the data in the .xls file, but i am running into some problems when i try to insert data into the file. Here is the code i use the insert data
Code:
Dim DS As System.Data.DataSet
Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
Dim MyConnection As System.Data.OleDb.OleDbConnection
MyConnection = New System.Data.OleDb.OleDbConnection( _
"provider=Microsoft.Jet.OLEDB.4.0; " & _
"data source=C:\Documents and settings\modonnell.itec\my Documents\Excel_Trial.XLS; " & _
"Extended Properties=Excel 8.0;")
Select the data from Sheet1 of the workbook.
MyCommand = New System.Data.OleDb.OleDbDataAdapter( _
"select * from [Sheet1$C4:E14]", MyConnection)
DS = New System.Data.DataSet
MyCommand.Fill(DS)
MyConnection.Close()
Return DS
End Function
While for the insert statement i am doing the following:
Code:
Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
Dim MyConnection As System.Data.OleDb.OleDbConnection
MyConnection = New System.Data.OleDb.OleDbConnection( _
"provider=Microsoft.Jet.OLEDB.4.0; " & _
"data source=C:\Documents and settings\modonnell.itec\my Documents\Excel_Trial.XLS; " & _
"Extended Properties=Excel 8.0;")
Select the data from Sheet1 of the workbook.
MyCommand = New System.Data.OleDb.OleDbDataAdapter( _
"insert into [Sheet1$B15:E15] values (1, Mike, RR55, WORKING ", MyConnection)
MyConnection.Close()
End Function
Any suggestions welcomed, not even sure if you can do an insert statement. Am working with a web project not a windows project.
Mike55
Last edited by a moderator: