如果在ado.net中存在命令怎么写? [英] how to write if exist command in ado.net?

查看:50
本文介绍了如果在ado.net中存在命令怎么写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

how to write if exist command in ado.net?




string s = "select * from " + U_name.Text + "where Image=@Image IF EXIST ";



ADO.NET

无法在命令之上工作...

帮助我


ADO.NET
not working above command ...
help me

推荐答案

首先,不要连接字符串来构建SQL命令。它让您对意外或故意的SQL注入攻击持开放态度,这可能会破坏您的整个数据库。使用参数化查询 - 就像在WHERE子句中一样。



其次,尝试:

Firstly, 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 - just like you do in the WHERE clause.

Secondly, try:
WHERE [Image] IS NOT NULL AND [Image]=@Image



(图像是一种SQL数据类型,因此是一个关键字:你需要使用括号围绕它来使用它作为列名。)


("Image" is an SQL datatype, and thus a keyword: you need to use brackets round it to use it as a column name.)


这篇关于如果在ado.net中存在命令怎么写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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