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. Database & SysAdmin
  3. Database
  4. MS Access and C# Help

MS Access and C# Help

Scheduled Pinned Locked Moved Database
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

    C 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

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      achrafus wrote:

      the odbc driver it says not enough parameters or something.

      That's a bit vague - What is the EXACT error message? (From other things you've said I think I know what the problem is, but this kind of vague reference to an error message really is not useful and can irritate many people. There are often two similar error messages where the actual root cause is substantially different)

      achrafus wrote:

      In my string i'm having only one parameter and it's @catName

      Access does not use named parameters, use ? (the question-mark) and add the parameters in the order they appear in the query.


      "On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog

      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