特殊字符的异常 [英] exception with special characters

查看:124
本文介绍了特殊字符的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下查询与SQL查询分析器完美匹配:


插入TableName(ID,ParamName,ParamValue)值

(27706,'' Param6'',''\ 0V * \ 0 \ 0 \ 0 \ 0 \ 0'')


但是如果我尝试使用相同的查询执行OdbcCommand对象,它会抛出

异常。任何帮助PLZ?

The following query runs perfectly fine with SQL Query Analyzer:

insert into TableName(ID,ParamName,ParamValue) values
(27706,''Param6'',''\0V*\0\0\0\0\0'')

But if i try to execute the same query using OdbcCommand object, it throws
an exception. Any help plz?

推荐答案

Wajih-ur-Rehman< wr ***** @ ro1.adiscon.com>写道:
Wajih-ur-Rehman <wr*****@ro1.adiscon.com> wrote:
以下查询与SQL查询分析器完全匹配:

插入TableName(ID,ParamName,ParamValue)值
(27706,''Param6 '',''\ 0V * \ 0 \ 0 \ 0 \ 0 \ 0'')

但是如果我尝试使用OdbcCommand对象执行相同的查询,它会抛出
一个例外。任何帮助PLZ?
The following query runs perfectly fine with SQL Query Analyzer:

insert into TableName(ID,ParamName,ParamValue) values
(27706,''Param6'',''\0V*\0\0\0\0\0'')

But if i try to execute the same query using OdbcCommand object, it throws
an exception. Any help plz?




您是否尝试过在SQL语句中使用参数而不是直接包含空值




-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet

如果回复该群组,请不要给我发邮件



Have you tried using parameters instead of including the nulls directly
in the SQL statement?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


我在使用OdbcCommand对象进行参数化查询时遇到问题。

如果我设置它的事件?而不是@仍然会引发异常。你可以给我b $ b指导我一点吗?你认为它会解决这个问题吗?


" Jon Skeet [C#MVP]" < SK *** @ pobox.com>在消息中写道

新闻:MP ************************ @ msnews.microsoft.c om ...

Wajih-ur-Rehman< wr ***** @ ro1.adiscon.com>写道:
I am having problems with parameterized queries with OdbcCommand object.
Event if i set it with ? instead of @ still it throws an exception. Can you
guide me a little on this? Do you think that it will solve the problem?

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Wajih-ur-Rehman <wr*****@ro1.adiscon.com> wrote:
以下查询与SQL查询分析器完全匹配:

插入TableName(ID,ParamName,ParamValue)值
(27706,''Param6 '',''\ 0V * \ 0 \ 0 \ 0 \ 0 \ 0'')

但是如果我尝试使用OdbcCommand对象执行相同的查询,它会抛出
一个例外。任何帮助PLZ?
The following query runs perfectly fine with SQL Query Analyzer:

insert into TableName(ID,ParamName,ParamValue) values
(27706,''Param6'',''\0V*\0\0\0\0\0'')

But if i try to execute the same query using OdbcCommand object, it throws
an exception. Any help plz?




您是否尝试过在SQL语句中使用参数而不是直接包含空值




-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet

如果回复该群组,请不要给我发邮件



Have you tried using parameters instead of including the nulls directly
in the SQL statement?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Wajih-ur-Rehman< wr ***** @ ro1.adiscon.com>写道:
Wajih-ur-Rehman <wr*****@ro1.adiscon.com> wrote:
我遇到了使用OdbcCommand对象进行参数化查询的问题。
如果我设置它的事件?而不是@仍然会引发异常。你能指导我一点吗?你认为它会解决这个问题吗?
I am having problems with parameterized queries with OdbcCommand object.
Event if i set it with ? instead of @ still it throws an exception. Can you
guide me a little on this? Do you think that it will solve the problem?




究竟是什么例外?你可以发一个简短但是完美的程序来证明这个问题吗?


http://www.pobox.com/~skeet/csharp/complete.html 了解详情

我的意思是什么。


无论它是否解决了这个特殊问题,参数化都非常重要,以至于值得让它工作现在,然后

看看它是否有助于解决您的问题。


-

Jon Skeet - < sk * **@pobox.com>
http://www.pobox.com/ 〜双向飞碟

如果回复小组,请不要给我发邮件



What exception is it throwing, exactly? Could you post a short but
complete program which demonstrates the problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

Whether or not it solves this particular problem, parameterisation is
important enough that it''s worth getting it working now, and then
seeing whether it helps with your immediate problem.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


这篇关于特殊字符的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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