Runtime error TOO FEW PARAMETERS, EXPECTED 1

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • prakashleo
    New Member
    • Dec 2006
    • 9

    Runtime error TOO FEW PARAMETERS, EXPECTED 1

    hi ppl!

    here i'm getting an runtime error (Too Few Parameters, expected 1) while executing a query with vb which is running perfectly while executing from msaccess. pls pls help me in solving this. its littlebit urgent.

    here the queries;
    executed in msaccess,

    SELECT ITEM_MASTER.ITE M_NO, ITEM_MASTER.INT ERNAL_DESC, ITEM_MASTER.UOM _CODE, ITEM_MASTER.FLA G_NO, ITEM_REFERENCE. ORGAN_REF_CODE, ITEM_REFERENCE. ORGAN_CAT, ITEM_MASTER.LON G_DESC, ITEM_MASTER.UPD _ON, ITEM_MASTER.INS ERTED_ON, ITEM_MASTER.EXP ORT_FLAG, ITEM_MASTER.ITE M_ID, ITEM_REFERENCE. ORGAN_CODE
    FROM ITEM_REFERENCE RIGHT JOIN ITEM_MASTER ON ITEM_REFERENCE. ITEM_ID = ITEM_MASTER.ITE M_ID
    WHERE (((ITEM_MASTER. INSERTED_ON) Between #3/30/2007# And #4/4/2007#))
    ORDER BY ITEM_MASTER.ITE M_NO;

    exceuted in vb, throwing error,

    SELECT ITEM_MASTER.ITE M_NO, ITEM_MASTER.INT ERNAL_DESC, ITEM_MASTER.UOM _CODE, ITEM_MASTER.FLA G_NO, ITEM_REFERENCE. ORGAN_REF_CODE, ITEM_REFERENCE. ORGAN_CAT, ITEM_MASTER.LON G_DESC, ITEM_MASTER.UPD _ON, ITEM_MASTER.INS ERTED_ON, ITEM_MASTER.EXP ORT_FLAG,ITEM_M ASTER.ITEM_ID,I TEM_REFERENCE.O RGAN_CODE FROM ITEM_REFERENCE RIGHT JOIN ITEM_MASTER ON ITEM_REFERENCE. ITEM_ID = ITEM_MASTER.ITE M_ID WHERE (((ITEM_MASTER. INSERTED_ON) Between " & txt_from.Text & " And " & txt_to.Text & "))ORDER BY ITEM_MASTER.ITE M_NO")

    by
    prakash
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Depending on the version of VB and how you are using this SQL, the problem might be that you are including your control names rather than their values within the SQL string, and the SQL interpreter doesn't know what to do with them.

    Can you show us the actual piece of code which builds/uses this SQL string?

    And what version of VB are you using?

    Oh, one other thing. If INSERTED_ON is a date field, you should be putting # delimiters around the values you're comparing it to.

    Comment

    • prakashleo
      New Member
      • Dec 2006
      • 9

      #3
      version - vb 6.0
      dtp1 and 2 are datepicker control names

      tmp = "#" & DTP1.Value & "#"
      tmp1 = "#" & DTP2.Value & "#"
      txt_from.Text = tmp
      txt_to.Text = tmp1

      Set rdostr = cn.Execute("SEL ECT ITEM_MASTER.ITE M_NO, ITEM_MASTER.INT ERNAL_DESC, ITEM_MASTER.UOM _CODE, ITEM_MASTER.FLA G_NO, ITEM_REFERENCE. ORGAN_REF_CODE, ITEM_REFERENCE. ORGAN_CAT, ITEM_MASTER.LON G_DESC, ITEM_MASTER.UPD _ON, ITEM_MASTER.INS ERTED_ON, ITEM_MASTER.EXP ORT_FLAG,ITEM_M ASTER.ITEM_ID,I TEM_REFERENCE.O RGAN_CODE FROM ITEM_REFERENCE RIGHT JOIN ITEM_MASTER ON ITEM_REFERENCE. ITEM_ID = ITEM_MASTER.ITE M_ID WHERE (((ITEM_MASTER. INSERTED_ON) Between " & txt_from.Text & " And " & txt_to.Text & "))ORDER BY ITEM_MASTER.ITE M_NO")

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Did this work?

        (You might need to explicitly format the date values as mm/dd/yyyy, since this is the format that SQL requires.)

        Comment

        Working...