UPDATE statement in EXCEL file

jdy0803

Well-known member
Joined
Sep 9, 2012
Messages
73
Location
Santa Clarita
Programming Experience
10+
(This may be simillar question as previous issue, but I tried UPDATE command at this time, so I uploaded this post separately)

I'm trying updating EXCEL file.
No error occurs but data is not updated.
Can anybody review this code and give me some advice?
--------------
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim Sql As String
Dim records As Integer


cn = New OleDbConnection(Provider=Micorosft.jet.oledb.4.0;Data Source=C:\Company.xls;Extended Properties = ""Excel 8.0;HDR=Yes""")
cn.Open()
Sql = "UPDATE [Sheet1$] SET companyname = 'IBM', saved = 'Y' WHERE no = 1"
cmd = New OleDbCommand(Sql, cn)
records = cmd.ExecuteNonQuery()
cmd.Dispose()
cn.Close()
--------------
 
Last edited:
Back
Top