Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Updaing excel file using oleDb in c#

Updaing excel file using oleDb in c#

Scheduled Pinned Locked Moved ASP.NET
helpcsharpquestionannouncementlearning
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Neel07
    wrote on last edited by
    #1

    Am trying to update one cell in excel file using oleDb in c# but I get the following error "Concurrency violation: the UpdateCommand affected 0 records" Many thanks for ur help Excel File Test.xls structure (cell format for both these columns are Text in excel) Col1 Col2 1 100 code snippet using System.Data.OleDb; string ExcelConStr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Test.xls;Extended Properties=Excel 8.0;"; OleDbConnection oleDbConn = new OleDbConnection(ExcelConStr); oleDbConn.Open(); OleDbDataAdapter da = new OleDbDataAdapter("Select * from [Sheet1$]",oleDbConn) DataSet ds = new DataSet(); da.Fill(ds); da.UpdateCommand = new OleDbCommand("Update [Sheet1$] SET Col2= ? Where Col1= ?",oleDbConn); da.UpdateCommand.Parameters.Add("Col1",OleDbType.VarChar,255,"Col1"); da.UpdateCommand.Parameters.Add("Col2",OleDbType.VarChar,255,"Col2"); ds.Tables[0].Rows[0]["Col2"]=500; da.update(ds); Share knowledge to enhance your learning

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups