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. ADO.NET

ADO.NET

Scheduled Pinned Locked Moved ASP.NET
databasehelpcsharpasp-netquestion
2 Posts 2 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.
  • P Offline
    P Offline
    Peter Molnar
    wrote on last edited by
    #1

    Hello, I am new to ASP.NET, therefore I have a simple question: I want to read and update an existing row in my database with some new information. I have no problem with reading but very much problem with updating. I tried the below code, and I get a runtime error: System.Data.OleDb.OleDbException: Operation must use an updateable query. in the line: myAdapter.Update(myDataSet,"Tasks"); If I try UPDATE instead of SELECT in the SQL statement then I get: System.Data.OleDb.OleDbException: Syntax error in UPDATE statement. in the line: myAdapter.Fill(myDataSet,"Tasks"); This my code:

    OleDbConnection myConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;"
    +"Data Source=c:\\data.mdb");

    myConnection.Open();

    OleDbDataAdapter myAdapter = new OleDbDataAdapter("SELECT * FROM Tasks",myConnection);

    OleDbCommandBuilder myBuild = new OleDbCommandBuilder(myAdapter);

    DataSet myDataSet = new DataSet();

    myAdapter.Fill(myDataSet,"Tasks");

    TextBox1.Text = String.Format("{0}", myDataSet.Tables["Tasks"].Rows[0]["Number"]);
    myDataSet.Tables["Tasks"].Rows[0]["Company"] = "Text"; //This is where I update the DataSet

    myAdapter.Update(myDataSet,"Tasks");
    myConnection.Close();

    Peter Molnar

    M 1 Reply Last reply
    0
    • P Peter Molnar

      Hello, I am new to ASP.NET, therefore I have a simple question: I want to read and update an existing row in my database with some new information. I have no problem with reading but very much problem with updating. I tried the below code, and I get a runtime error: System.Data.OleDb.OleDbException: Operation must use an updateable query. in the line: myAdapter.Update(myDataSet,"Tasks"); If I try UPDATE instead of SELECT in the SQL statement then I get: System.Data.OleDb.OleDbException: Syntax error in UPDATE statement. in the line: myAdapter.Fill(myDataSet,"Tasks"); This my code:

      OleDbConnection myConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;"
      +"Data Source=c:\\data.mdb");

      myConnection.Open();

      OleDbDataAdapter myAdapter = new OleDbDataAdapter("SELECT * FROM Tasks",myConnection);

      OleDbCommandBuilder myBuild = new OleDbCommandBuilder(myAdapter);

      DataSet myDataSet = new DataSet();

      myAdapter.Fill(myDataSet,"Tasks");

      TextBox1.Text = String.Format("{0}", myDataSet.Tables["Tasks"].Rows[0]["Number"]);
      myDataSet.Tables["Tasks"].Rows[0]["Company"] = "Text"; //This is where I update the DataSet

      myAdapter.Update(myDataSet,"Tasks");
      myConnection.Close();

      Peter Molnar

      M Offline
      M Offline
      Marcie Jones
      wrote on last edited by
      #2

      Hi Peter, This is generally a permissions issue. Make sure the ASPNET user has read and write rights to the folder containing your MDB. Hope that helps! Datagrid Girl

      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