Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Error incorect sintax dbo or incorect sinaxt worker, if delete dbo...

What I have tried:

string pronadji = "SELECT brojprijavnice2 AS Redni_broj, radnik AS Radnik, vrijemeprijave AS Vrijeme_Prijave, vrijemeodjave AS Vrijeme_odjave"
                                + "FROM dbo.worker WHERE vrijemeprijave <= convert(date, getDate()) and vrijemeodjave <= convert(date, getDate()) and status = 'odjavljen'";
Posted
Updated 13-Mar-18 6:17am

You're missing a space before "FROM" but please look into SQL Injection and research how to pass parameters to SQL queries safely.
 
Share this answer
 
Comments
#realJSOP 13-Mar-18 12:21pm    
I didn't catch that. He'd been warned about sql injection prior to this question.
PeejayAdams 13-Mar-18 12:30pm    
Horses and water.
The only thing I can see right off hand is that you should put square brackets around the field "status". It's a reserved word in SQL.

Along with that, you should also do convert(date, ...) on the field names as well, to make sure you're just comparing dates.

You may also want to qualify the table name with the name of the database (this is probably your actual problem).

[mydatabase].[dbo].[worker]

For what it's worth, you should always enclose field names, and table names with square brackets just to make sure you're not colliding with SQL reserved words, as well as fully qualifying table names as shown above.
 
Share this answer
 
v2

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