.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ADO.Net >> Post New QuestionBookmark and Share Subscribe to Forum

not able to insert data into excel sheet through windows application in visual studio 2008

Posted By: vinay     Posted Date: December 15, 2010    Points:2   Category :ADO.Net
Error:
The Microsoft Jet database engine could not find the object 'c:\travel.xls'. Make sure the object exists and that you spell its name and the path name correctly.

following is the code am using:
Dim num As Integer
Dim MyConnection As System.Data.OleDb.OleDbConnection
Dim myCommand As New System.Data.OleDb.OleDbCommand
Dim sql As String

MyConnection = New System.Data.OleDb.OleDbConnection _
("provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + _
"'c:\\travel.xls';Extended Properties=""Excel 8.0;HDR=NO;IMEX=1""")

MyConnection.Open()
myCommand.Connection = MyConnection
sql = "Insert into [vayama$] (id,name) values('5','e')"
myCommand.CommandText = sql
num = myCommand.ExecuteNonQuery()
MyConnection.Close()

Responses
Author: Raga             
Posted Date: March 02, 2011     Points: 20   

Try with the following MyConnection = New System.Data.OleDb.OleDbConnection _
("provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + _
"c:\\travel.xls;Extended Properties=""Excel 8.0;HDR=NO;IMEX=1""")

You can direcly give the Filepath. We need not use single quotes.





Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend