Click here to Skip to main content
15,889,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want to display the data based on today date.
I got error to display data into gridview. This is the error "Incorrect syntax near the keyword 'where'."...
Hope anybody help me....
VB
        Dim queryString1 As String = "SELECT     A.ExitID, A.EmpNo, B.Name, A.DeptmtID, CONVERT(varchar, A.ExitTimeFrom, 103) AS ExitTimeFrom, CONVERT(varchar, A.ExitTimeTo, 103) 
                      AS ExitTimeTo, A.ExitFrom, A.ExitTo, C.ExitStatus, A.Purpose
FROM         ExitPassDetails AS A LEFT OUTER JOIN
                      CMOS.dbo.Boss_Employee_Profile AS B ON A.EmpNo = B.EmpNo LEFT OUTER JOIN
                      ExitPassStatus AS C ON A.ExitStatus = C.StatusID
WHERE     (A.ExitTimeFrom >= DATEPART(m, GETDATE()))
ORDER BY ExitTimeFrom DESC"

Thanks
BB
Posted
Updated 5-May-11 18:11pm
v2
Comments
Simon_Whale 6-May-11 5:36am    
Does the query work if your directly execute it on the database?
Reena Aleesya 8-May-11 21:29pm    
yes..

SQL
WHERE (CONVERT(varchar, A.ExitTimeFrom, 103) >=  CONVERT(varchar, GETDATE(), 103))
 
Share this answer
 
Comments
Reena Aleesya 6-May-11 3:55am    
Hi Sunasara,
i already tested but still got same error..
once i'm browse it will highlight part of this coding

<pre lang="vb">Dim ds As DataSet = New DataSet
If RadioButton1.Checked = True Then
adapter1.Fill(ds, "ExitPassTable")
GridViewExcel.DataSource = ds
GridViewExcel.DataBind()
ElseIf DropDownList1.SelectedValue <> "" Then
adapter1.Fill(ds, "ExitPassTable")
GridViewExcel.DataSource = ds
GridViewExcel.DataBind()</pre>

and show error message:
"Incorrect syntax near the keyword 'where'."...

Any idea how to solve it?

rgds
BB
Sunasara Imdadhusen 6-May-11 4:49am    
A.ExitTimeFrom is DateTime type field?
Reena Aleesya 8-May-11 21:28pm    
yes..datetime..
i alter my coding and no more error..but still not display data for today..
thanks
BB
Thanks everyone..
this part solved..

Regards
BB
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900