Results 1 to 14 of 14

Thread: [RESOLVED] The Select statement includes a reserved word or an argument name that is misspelled

  1. #1

    Thread Starter
    Member kirara22's Avatar
    Join Date
    Feb 2009
    Posts
    54

    Resolved [RESOLVED] The Select statement includes a reserved word or an argument name that is misspelled

    hi guyz..

    i need to view the data on my database through datagrid in which the input date(month and year) is equal to the lastdate(month and year) field in my database.

    i got the following errror message:
    The Select statement includes a reserved word or an argument name that is misspelled or missing or the punctuation is incorrect"

    i made simple program attach here for you to help me out.

    vb6.rar



    im a student btw and working for my thesis. tnx
    im new at vb
    kindly plz help me. tnx
    Last edited by kirara22; Mar 16th, 2009 at 05:22 AM.

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: The Select statement includes a reserved word or an argument name that is misspelled

    What is your back end ?
    Please mark you thread resolved using the Thread Tools as shown

  3. #3

    Thread Starter
    Member kirara22's Avatar
    Join Date
    Feb 2009
    Posts
    54

    Re: The Select statement includes a reserved word or an argument name that is misspelled

    iam using VB6 ADO and access in back end

  4. #4
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: The Select statement includes a reserved word or an argument name that is misspelled

    As for as the Screen shot you have posted i could see that the Name is the Keyword for the Access. If you want to use the Name field in your query cover the field with [] like

    Code:
    Select [Name] from YourTable
    List of Access Keywords
    Please mark you thread resolved using the Thread Tools as shown

  5. #5

    Thread Starter
    Member kirara22's Avatar
    Join Date
    Feb 2009
    Posts
    54

    Re: The Select statement includes a reserved word or an argument name that is misspelled

    the keyword is the month and year.
    in a given example it is the the month 3 and year 2009
    which means march 2009

    in my datagrid i want it to display all the records on my database
    having the month "3" and year "2009" or march 2009

    below is the code in the VIEW RECORD command..

    Code:
    Private Sub Command2_Click()
    Dim lastdate As Date
    
    On Error GoTo errhandler
    
    mySql = "SELECT From db3 WHERE lastdate= MONTH(date)=" & (lblmonth.Caption) & " AND YEAR(date)=" & (lblyear.Caption) & "  GROUP BY YEAR(date),MONTH(date)"
    
    Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\My Documents\vb6\db3.mdb;Persist Security Info=False"
    Adodc1.CommandType = adCmdText
    Adodc1.RecordSource = mySql
    
    Set DataGrid1.DataSource = Adodc1
    Adodc1.Refresh
    DataGrid1.Refresh
    
    If Adodc1.Recordset.RecordCount = 0 Then
    errhandler:
    MsgBox "NO record"
    Else
    MsgBox Err.Description
    MsgBox Err.Number
    End If
    
    End Sub

  6. #6
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: The Select statement includes a reserved word or an argument name that is misspelled

    you are not retrieving any columns from the table ?

    Code:
    mySql = "SELECT From db3 WHERE lastdate= MONTH(date)=" & (lblmonth.Caption) & " AND YEAR(date)=" & (lblyear.Caption) & "  GROUP BY YEAR(date),MONTH(date)"
    Should be

    Code:
    mySql = "SELECT * From db3 WHERE lastdate= MONTH(date)=" & (lblmonth.Caption) & " AND YEAR(date)=" & (lblyear.Caption) & "  GROUP BY YEAR(date),MONTH(date)"
    Please mark you thread resolved using the Thread Tools as shown

  7. #7

    Thread Starter
    Member kirara22's Avatar
    Join Date
    Feb 2009
    Posts
    54

    Re: The Select statement includes a reserved word or an argument name that is misspelled

    ooppss sorry it must be the name of the table not the database file ^^
    db3=table1.. ehhehehe..
    and the date must be in the one in my field in the database? ^^
    date=last_date

    i have already update my attatchment
    hmmm...
    for those who will run my program must be located at C:\My Documents ^_^

    danasegarane i have already put an *

    Code:
    mySql = "SELECT *From table1 WHERE last_date=MONTH(last_date)=" & (lblmonth.Caption) & " AND YEAR(last_date)=" & (lblyear.Caption) & "  GROUP BY YEAR(last_date),MONTH(last_date)"
    but i've the following error message:

    cannot group on fields selected with '*'

  8. #8
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: The Select statement includes a reserved word or an argument name that is misspelled

    What are the fields you are trying to display ?
    Please mark you thread resolved using the Thread Tools as shown

  9. #9

    Thread Starter
    Member kirara22's Avatar
    Join Date
    Feb 2009
    Posts
    54

    Re: The Select statement includes a reserved word or an argument name that is misspelled

    the field name only

    in my example in will display on the datagrid

    name
    aaa
    bbb
    ccc
    ddd
    eee
    fff
    ggg
    hhh

    as the last_date field is = to 3/2009

    which is my input on the lblmonth.caption = 3
    and lblyear.caption = 2009

  10. #10
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: The Select statement includes a reserved word or an argument name that is misspelled

    Try

    vb Code:
    1. mySql = "SELECT [Name],last_date,[id]From table1 WHERE last_date=MONTH(last_date)=" & (lblmonth.Caption) & " AND YEAR(last_date)=" & (lblyear.Caption) & "  GROUP BY YEAR(last_date),MONTH(last_date),[Name],[id],last_date"
    Please mark you thread resolved using the Thread Tools as shown

  11. #11

    Thread Starter
    Member kirara22's Avatar
    Join Date
    Feb 2009
    Posts
    54

    Re: The Select statement includes a reserved word or an argument name that is misspelled

    using that code.. theirs no error message anymore..

    but

    still not able to display the data on my datagrid

    i really try coding but still nothing happen


    vb6.rar

    tnx danasegarane for helping me

  12. #12

    Thread Starter
    Member kirara22's Avatar
    Join Date
    Feb 2009
    Posts
    54

    Re: The Select statement includes a reserved word or an argument name that is misspelled

    danasegarane thanks a lot for your help

    you really help me a lot!

    i've successfully able to code it right.

    tnx a lot..

    GODBLESS AND MORE POWER

  13. #13
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: The Select statement includes a reserved word or an argument name that is misspelled

    I don't have access to test. Did you try the query in Query Analyzer?

    may be there will be no data for the particular condition
    Please mark you thread resolved using the Thread Tools as shown

  14. #14

    Thread Starter
    Member kirara22's Avatar
    Join Date
    Feb 2009
    Posts
    54

    Resolved Re: [RESOLVED] The Select statement includes a reserved word or an argument name that is misspelled

    nope i didnt try that...

    but its now working well...

    tnx

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