错误导致sintax dbo [英] Error incorect sintax dbo

查看:73
本文介绍了错误导致sintax dbo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误导致sintax dbo或incorect sinaxt worker,如果删除dbo ...



我尝试过:



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'";

推荐答案

你在FROM之前缺少一个空格但是请查看SQL注入并研究如何传递参数安全地进行SQL查询。
You're missing a space before "FROM" but please look into SQL Injection and research how to pass parameters to SQL queries safely.


我唯一可以看到的就是你应该在字段status周围加上方括号。这是SQL中的保留字。



除此之外,还应该 convert(date,...)关于字段名称,以确保您只是比较日期。



您可能还希望使用数据库名称限定表名(这可能是你的实际问题)。



[mydatabase]。[dbo]。[worker] < br $>


对于它的价值,你应该总是用字括号括起字段名和表名,以确保你不会与SQL保留字冲突,以及完全限定表名,如上所示。
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.


这篇关于错误导致sintax dbo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆