hi all,
I would like to understand how to update a cell value of excel file using ace.oledb and adapter.
I wrote following code:
I get error on:
this is message from VS: "no specified value for some needed parameters"
Legend:
[Sectors$] is sheet of excel file
[Sector UID] is column that contains strings "MN064U1", "MN064U2" and "MN064U3"
I would like to change i.e. string "MN064U1" with "test" and update excel file
I believe that issue is on command:
but I cannot understand how to set it.
thanks in advanced
giodepa
I would like to understand how to update a cell value of excel file using ace.oledb and adapter.
I wrote following code:
Excelconnection = New OleDbConnection("provider=Microsoft.ACE.OLEDB.12.0; data source=" + mypath + "; Extended Properties='Excel 12.0;HDR=Yes;IMEX=1'") Excelconnection.Open() mySelectQuery = "SELECT * FROM [Sectors$]" + " WHERE " + "[Sector UID]" + " LIKE 'MN064U%';" Dim MYTABLE As New DataSet Dim adapter As New OleDbDataAdapter(mySelectQuery, Excelconnection) adapter.Fill(MYTABLE) Dim aaa As DataRow = MYTABLE.Tables(0).Rows(0) aaa.BeginEdit() aaa.Item(0) = "test" aaa.EndEdit() Dim updatecommand = New OleDbCommand("UPDATE [Sectors$] SET" + " [Sector UID]" + " =? WHERE " + "[Sector UID]" + " = ?;", Excelconnection) updatecommand.Parameters.Add("Sector UID", OleDbType.Variant, 10, "Sector UID") adapter.UpdateCommand = updatecommand adapter.Update(MYTABLE) Excelconnection.Close() adapter.Dispose()
I get error on:
adapter.Update(MYTABLE)
this is message from VS: "no specified value for some needed parameters"
Legend:
[Sectors$] is sheet of excel file
[Sector UID] is column that contains strings "MN064U1", "MN064U2" and "MN064U3"
I would like to change i.e. string "MN064U1" with "test" and update excel file
I believe that issue is on command:
Dim updatecommand = New OleDbCommand("UPDATE [Sectors$] SET" + " [Sector UID]" + " =? WHERE " + "[Sector UID]" + " = ?;", Excelconnection)
but I cannot understand how to set it.
thanks in advanced
giodepa