Use Ado.net to update individual cells in Excel

L

Lisa

Hi!!
Can any one help me get this info -
Update individual cells in Excel using ADO.NET

I keep getting error in the update statement.

Thanks for any help in advance!!

Here is my code -


Dim connString As String
connString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=ExcelData1.xls;" & _
"Extended Properties=""Excel 8.0;HDR=YES"""

objconnection = New OleDbConnection(connString)
objconnection.Open() 'open the connection

Dim cmd1 As New OleDbCommand
cmd1.Connection = objConnection

cmd1.CommandText = "INSERT INTO EmployeeData1 (Id, Name,
BirthDate) values ('AAA12', 'Andrew21', '12/4/1955')"

cmd1.ExecuteNonQuery()



cmd1.CommandText = "UPDATE [EmployeeData1] SET id = 'ad',
A2 = 'Cell F3'" ', F2 = 'Cell G3' where F1<>'1'"

cmd1.ExecuteNonQuery()

objConnection.Close()
 
S

Steve Flitcroft

ty putting single quotes around and a dollar sign after the worksheet in
your statement
e.g
cmd1.CommandText = "UPDATE ['EmployeeData1$'] SET id = 'ad',
A2 = 'Cell F3'" ', F2 = 'Cell G3' where F1<>'1'"
 

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