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. C# and MS Access parameter passing

C# and MS Access parameter passing

Scheduled Pinned Locked Moved C#
csharpdatabasesql-serversysadminhelp
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.
  • A Offline
    A Offline
    achrafus
    wrote on last edited by
    #1

    hello every body, I usually work with sql server so if anybody may help with MS Access I'd be thankful. here 's my C# potion of code: string selectId = "select categoryId from Category where categoryName = @catName"; myCommand = new OdbcCommand(selectId,myConn); myCommand.Parameters.Add("@catName",categoryName.ToString()); myCommand.prepare(); myReader = myCommand.ExecuteReader(); at this level an exeption is thrown at the level of the odbc driver it says not enough parameters or something. 1 parameter missing. In my string i'm having only one parameter and it's @catName. in the definition of the Add()function it says that the second parameter is the value of the named parameter. The function that contains this code receives the value of categoryName however it's not set! can anybody help pls

    G 1 Reply Last reply
    0
    • A achrafus

      hello every body, I usually work with sql server so if anybody may help with MS Access I'd be thankful. here 's my C# potion of code: string selectId = "select categoryId from Category where categoryName = @catName"; myCommand = new OdbcCommand(selectId,myConn); myCommand.Parameters.Add("@catName",categoryName.ToString()); myCommand.prepare(); myReader = myCommand.ExecuteReader(); at this level an exeption is thrown at the level of the odbc driver it says not enough parameters or something. 1 parameter missing. In my string i'm having only one parameter and it's @catName. in the definition of the Add()function it says that the second parameter is the value of the named parameter. The function that contains this code receives the value of categoryName however it's not set! can anybody help pls

      G Offline
      G Offline
      Graham Nimbley
      wrote on last edited by
      #2

      Should be this...?

      myCommand.Parameters.Add("catName",categoryName.ToString());

      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