How to insert data into an existing Excel table

  • Thread starter Thread starter Mamatha
  • Start date Start date
M

Mamatha

I have one table in Excel database and i want to insert a
new row to that table.I don't have that much of knowledge
to insert a new row into that table through VB.NET.If any
one can know,Please reply me..

Mamatha
 
¤ I have one table in Excel database and i want to insert a
¤ new row to that table.I don't have that much of knowledge
¤ to insert a new row into that table through VB.NET.If any
¤ one can know,Please reply me..

You can use ADO.NET to do this:

Dim ConnectionString As String

ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=e:\My Documents\Book20.xls;Extended Properties=""Excel 8.0;HDR=NO"""

Dim ExcelConnection As New System.Data.OleDb.OleDbConnection(ConnectionString)
ExcelConnection.Open()

Dim ExcelCommand As System.Data.OleDb.OleDbCommand = ExcelConnection.CreateCommand()

ExcelCommand.CommandText = "Insert Into [Table4$] (F1, F2, F3) Values (9, 'new', 'row')"
ExcelCommand.CommandType = CommandType.Text
ExcelCommand.ExecuteNonQuery()

ExcelConnection.Close()


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top