我从sql server2008数据库中得不到任何东西 [英] I get no thing from sql server2008 data base

查看:98
本文介绍了我从sql server2008数据库中得不到任何东西的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨:

我的win表单应用程序有问题

我在sql server2008数据库中得不到任何东西:

select ID where = textbox.text

my textbox.text是一个法罗文本

hi :
I have a problem with my win form application
I get no thing from sql server2008 data base when I:
select ID where = textbox.text
my textbox.text is a faroese text

推荐答案

SQL LIKE子句需要使用通配符:如果是没有出现在你的文本框中,那就等于等于。



尝试:

The SQL LIKE clause needs wildcards: if they are not present in your textbox, then it is the equivalent of equals.

Try:
SqlDataAdapter dan = new SqlDataAdapter("SELECT ID FROM t1 WHERE no LIKE '%" + textBox1.Text + "%'", conn);





但请不要这样做!不要连接字符串以构建SQL命令。它让您对意外或故意的SQL注入攻击持开放态度,这可能会破坏您的整个数据库。请改用参数化查询。



But please, don't do it like that! 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.


我只需输入N:)

I just put the "N" :)
<pre lang="c#">SqlDataAdapter dan = new SqlDataAdapter(" select ID from t1 where no like N'%" +textBox1.Text+"%'", conn);


这篇关于我从sql server2008数据库中得不到任何东西的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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