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. Trouble with an SQL statement...maybe syntax related?

Trouble with an SQL statement...maybe syntax related?

Scheduled Pinned Locked Moved Database
helpcsharpdatabasequestion
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.
  • F Offline
    F Offline
    frank21
    wrote on last edited by
    #1

    Hello, I have a c# code file and within it I have the following code: private void Page_Load(object sender, System.EventArgs e) { DBReader("SELECT PackageNumber FROM Packages WHERE Packages.PackageID = Level1Packages.PackageID"); } private void DBReader(string SQLQuery) { if(!IsPostBack) { OleDbCommand myCommand = new OleDbCommand(SQLQuery,oleDbConnection1); oleDbConnection1.Open(); dataReader = myCommand.ExecuteReader(); ******* while(dataReader.Read()) { this.Lvl1PackageNumListBox.Items.Add(dataReader.GetString(0)); } oleDbConnection1.Close(); } } The code dies on the line with stars with the error message "no value given for one or more parameters". I think the problem lies in my SQl statement I am passing to the DBReader method. I am not sure if using the . operator is correct when trying to access a column of a table. Thanks for helping out a newbie! Frank

    C 1 Reply Last reply
    0
    • F frank21

      Hello, I have a c# code file and within it I have the following code: private void Page_Load(object sender, System.EventArgs e) { DBReader("SELECT PackageNumber FROM Packages WHERE Packages.PackageID = Level1Packages.PackageID"); } private void DBReader(string SQLQuery) { if(!IsPostBack) { OleDbCommand myCommand = new OleDbCommand(SQLQuery,oleDbConnection1); oleDbConnection1.Open(); dataReader = myCommand.ExecuteReader(); ******* while(dataReader.Read()) { this.Lvl1PackageNumListBox.Items.Add(dataReader.GetString(0)); } oleDbConnection1.Close(); } } The code dies on the line with stars with the error message "no value given for one or more parameters". I think the problem lies in my SQl statement I am passing to the DBReader method. I am not sure if using the . operator is correct when trying to access a column of a table. Thanks for helping out a newbie! Frank

      C Offline
      C Offline
      Chris Meech
      wrote on last edited by
      #2

      Going out on a limb here, but change the SQL to be

      SELECT PackageNumber FROM Packages**,Level1Packages** WHERE Packages.PackageID = Level1Packages.PackageID,

      Chris Meech It's much easier to get rich telling people what they want to hear. Chistopher Duncan I can't help getting older, but I refuse to grow up. Roger Wright I've been meaning to change my sig. Thanks! Alvaro Mendez We're more like a hobbiest in a Home Depot drooling at all the shiny power tools, rather than a craftsman that makes the chair to an exacting level of comfort by measuring the customer's butt. Marc Clifton

      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