1 Attachment(s)
[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.
Attachment 69735
http://www.fileden.com/files/2008/3/26/1838035/vb.JPG
im a student btw and working for my thesis. tnx
im new at vb:o
kindly plz help me. tnx :)
Re: The Select statement includes a reserved word or an argument name that is misspelled
Re: The Select statement includes a reserved word or an argument name that is misspelled
iam using VB6 ADO and access in back end
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
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
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)"
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:
:confused:
cannot group on fields selected with '*'
Re: The Select statement includes a reserved word or an argument name that is misspelled
What are the fields you are trying to display ?
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
Re: The Select statement includes a reserved word or an argument name that is misspelled
Try
vb Code:
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"
1 Attachment(s)
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 :(
Attachment 69741
tnx danasegarane for helping me
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 :)
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
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 :)