更正SQL查询

编程入门 行业动态 更新时间:2024-10-12 08:26:39
本文介绍了更正SQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

select SheetNo,TotalDays,COALESCE(CONVERT(CHAR(8), FDate, 1), '''') + ''-''+ COALESCE(CONVERT(CHAR(8), TDate, 1), '''') AS Peroids,VehicleNo,Driver1+''/''+Driver2 as Driver,Tfrieght as Frieght,TDQty as Diesel_Qty,TDAmt as Diesel_Amt,TEAmt as Expense,NetBal,TKM,Mile as Milage from TripSheet where convert(datetime, EDate, 103) between ''" & dtp_from.Value.Date & "'' and ''" & dtp_to.Value.Date & "'' and Driver1=''" & cb_sublist.Text & "'' union all select SheetNo,TotalDays,COALESCE(CONVERT(CHAR(8), FDate, 1), '''') + ''-''+ COALESCE(CONVERT(CHAR(8), TDate, 1), '''') AS Peroids,VehicleNo,Driver1+''/''+Driver2 as Driver,Tfrieght as Frieght,TDQty as Diesel_Qty,TDAmt as Diesel_Amt,TEAmt as Expense,NetBal,TKM,Mile as Milage from TripSheet where convert(datetime, EDate, 103) between ''" & dtp_from.Value.Date & "'' and ''" & dtp_to.Value.Date & "'' and Driver2='' " & cb_sublist.Text & " ''

这是正确的方法吗?...

Is this correct od not....

推荐答案

我们怎么知道? 我们不知道您的数据库是什么样子! 但是-尽管很大,但是-不要串联字符串来构建SQL命令.它使您对意外或蓄意的SQL注入攻击敞开大门,这可能会破坏整个数据库.改为使用参数化查询. How would we know? We have no idea what your database looks like! But - and it''s a big but - do not concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.

更多推荐

更正SQL查询

本文发布于:2023-11-22 06:07:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1616258.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!