CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2003
    Location
    Cardiff and Oxford
    Posts
    44

    Why wont this INNER JOIN work

    I am joining two tables together using INNER join. I want some of the feilds from one table (stockLevels) and some fields from the other (productFile).

    When select all fields it works fine:

    SELECT * FROM stockLevels INNER JOIN productFile ON productFile.ProductID = stockLevels.productID;


    but when I start to choose the fields Even one I get an error.


    Dim sqlQuery2 As String = "select stoclLevels.name, productFile.costPrice from stockLevels INNER JOIN productFile ON productFile.ProductID = stockLevels.productID"



    No value givern fore one or more paramiters.


    The SQL command I would like to execute is:


    Dim sqlQuery2 As String = "SELECT productFile.supplierID, productFile.productID, productFile.ProdctName, productFile.costPrice, productFile.servingsPerUnit, stockLvels.servings, stockLevels.reorderLevel, stockLevels.NormaLevel FROM productFile INNER JOIN stockLevels ON productFile.ProductID = stockLevels.productID ;"



    Thanks for reading an please help

    scottie.uk

  2. #2
    Join Date
    Nov 2002
    Location
    Tatooine
    Posts
    155
    Did you check the spelling of all the fields? In the example you posted one of the fields is spelled wrong, stockLvels.servings.
    That which does not kill us, only makes us stronger.

    MCSD .NET

  3. #3
    Join Date
    Mar 2003
    Location
    Cardiff and Oxford
    Posts
    44
    Thanks that was an error, I did manage to get it working after a while. Some of the words in the original database had spaces between them, wheres in my code I did not.

    Thanks for the help.


  4. #4
    Join Date
    May 2003
    Location
    Nanded
    Posts
    2

    Mispelled Query

    When u use all the fields that quary possess all the names in database exactly as they are in queries but in the following query u used first filed as follows "stoclLevels.name" and this field really not present your field might be as follows "stockLevels.name"

    so u retype this quary or just pick the following query.

    Dim sqlQuery2 As String = "select stockLevels.name, productFile.costPrice from stockLevels INNER JOIN productFile ON productFile.ProductID = stockLevels.productID"


    Hope it will solve your problem



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured