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. General Programming
  3. C#
  4. Enterprise Library with Microsoft Access [modified]

Enterprise Library with Microsoft Access [modified]

Scheduled Pinned Locked Moved C#
databasehelptutorialannouncement
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.
  • T Offline
    T Offline
    Tiger456
    wrote on last edited by
    #1

    Hi, How to pass parameters to a Access database using oledb provider and enterprise library. We used below code to update category table which has two colums ID and CategoryName. The code runs successfully without any errors but the table row remains unchanged. What could be the problem

    Database db = DatabaseFactory.CreateDatabase("MyDemoConnection");
    DbCommand dbCommand = db.GetSqlStringCommand("Update Category SET CategoryName = @CategoryName WHERE ID = @ID");
    db.AddInParameter(dbCommand, "@ID", DbType.Int32,(int) 1);
    db.AddInParameter(dbCommand, "@CategoryName", DbType.String, "Just a Change");

            // Execute command
            int i = db.ExecuteNonQuery(dbCommand);
    

    <connectionStrings>
    <add name="MyDemoConnection"
    connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\db1.mdb;User Id=admin;Password=;"
    providerName="System.Data.OleDb"/>
    </connectionStrings>

    It would be great if any one can redirect me to the exact way

    modified on Friday, August 21, 2009 7:21 AM

    L 1 Reply Last reply
    0
    • T Tiger456

      Hi, How to pass parameters to a Access database using oledb provider and enterprise library. We used below code to update category table which has two colums ID and CategoryName. The code runs successfully without any errors but the table row remains unchanged. What could be the problem

      Database db = DatabaseFactory.CreateDatabase("MyDemoConnection");
      DbCommand dbCommand = db.GetSqlStringCommand("Update Category SET CategoryName = @CategoryName WHERE ID = @ID");
      db.AddInParameter(dbCommand, "@ID", DbType.Int32,(int) 1);
      db.AddInParameter(dbCommand, "@CategoryName", DbType.String, "Just a Change");

              // Execute command
              int i = db.ExecuteNonQuery(dbCommand);
      

      <connectionStrings>
      <add name="MyDemoConnection"
      connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\db1.mdb;User Id=admin;Password=;"
      providerName="System.Data.OleDb"/>
      </connectionStrings>

      It would be great if any one can redirect me to the exact way

      modified on Friday, August 21, 2009 7:21 AM

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Here there is a simple solution. :)

      Life is a stage and we are all actors!

      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