解决程序的问题 [英] problem exectuing storded procedure

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

问题描述

嗨NG,


我有一个ASP脚本(使用Javascript)我通过POST发送数据。

这个数据存储在变量中将转移到SQL存储过程。

如下图所示...

welches eine变量übergeben

即将出现错误...

我不知道如何解决它,

请帮忙或给我一个提示......

[ asp代码行665和来自Functions.asp的+

var TopicName = String(Request.Form(" TopicName")));

var TopicContent = String(Request。表格(TopicContent));

var strSQL =" EXECUTE主题@TopicTitle = [" + TopicName +"],

@TopicContent = [" ; + TopicContent +"]" ;;

cmd.CommandText = strSQL;

cmd.Execute;

oDB_connect.close;

[/ asp code]


[错误页]

Fehlertyp:

Microsoft OLE DB Provider for ODBC驱动程序(0x80040E14)

[Micro软件] [ODBC SQL Server驱动程序] [SQL Server] Bezeichner(beginnend mit

''0123456789012345678901234567890123456789012345678 901234567890123456789012345678

9012345678901234567890123456789012345678901234567'')ist zu lang。死了

Maximall?nge betr?gt 128.

/Functions.asp,第669行

[/ error page]


[从存储过程中剪断]

CREATE PROCEDURE dbo.Topic @TopicTitle VARCHAR(20),@ TopContent VARCHAR(200)

AS INSERT INTO表.........等

[/从存储过程中剪切]

Hi NG,

I''ve got an ASP Script (useing Javascript) to which i send data to by POST.
This data stored in variables will be transferred to SQL stored Procedure.
As shown at bottom...
welches eine Variable übergeben
There is coming up an error...
I don''t know how to solve it,
please help or give me a hint...
[asp code line 665 and + from Functions.asp]
var TopicName=String(Request.Form("TopicName"));
var TopicContent=String(Request.Form ("TopicContent"));
var strSQL="EXECUTE Topic @TopicTitle=["+TopicName+"],
@TopicContent=["+TopicContent+"]";
cmd.CommandText = strSQL;
cmd.Execute;
oDB_connect.close;
[/asp code]

[error page]
Fehlertyp:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Bezeichner (beginnend mit
''0123456789012345678901234567890123456789012345678 901234567890123456789012345678
9012345678901234567890123456789012345678901234567'' ) ist zu lang. Die
Maximall?nge betr?gt 128.
/Functions.asp, line 669
[/error page]

[snip from Stored Procedure]
CREATE PROCEDURE dbo.Topic @TopicTitle VARCHAR(20), @TopicContent VARCHAR(200)
AS INSERT INTO Table.........etc
[/snip from Stored Procedure]

推荐答案

[发布和邮寄,请在新闻中回复]


Jan Schmidt(hi*****@gmx.net)写道:
[posted and mailed, please reply in news]

Jan Schmidt (hi*****@gmx.net) writes:
[asp code第665行和+来自Functions.asp]
var TopicName = String(Request.Form(" TopicName")));
var TopicContent = String(Request.Form(" TopicContent"));;
var strSQL =" EXECUTE主题@TopicTitle = [" + TopicName +"],
@TopicContent = [" + TopicContent +"]" ;;
cmd.CommandText = strSQL;
cmd.Execute;
oDB_connect.close;
[/ asp code]

[错误页面]
Fehlertyp:
微软OLE DB提供程序for ODBC Drivers(0x80040E14)
[Microsoft] [ODBC SQL Server驱动程序] [SQL Server] Bezeichner(beginnend mit

''0123456789012345678901234567890123456789012345678 90123456789012345678901234

5678 9012345678901234567890123456789012345678901234567' ')ist zu lang。模具
Maximall?nge betr?gt 128.
/Functions.asp,第669行
[/ error page]
[asp code line 665 and + from Functions.asp]
var TopicName=String(Request.Form("TopicName"));
var TopicContent=String(Request.Form ("TopicContent"));
var strSQL="EXECUTE Topic @TopicTitle=["+TopicName+"],
@TopicContent=["+TopicContent+"]";
cmd.CommandText = strSQL;
cmd.Execute;
oDB_connect.close;
[/asp code]

[error page]
Fehlertyp:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Bezeichner (beginnend mit
''0123456789012345678901234567890123456789012345678 90123456789012345678901234
5678 9012345678901234567890123456789012345678901234567'' ) ist zu lang. Die
Maximall?nge betr?gt 128.
/Functions.asp, line 669
[/error page]




之前我解决了你的实际问题,请允许我指出你使用MSDASQL提供程序,OLE DB over ODBC,你是
。使用SQLOLEDB提供程序

,因为此提供程序直接针对SQL Server而且更有效。
effecient。将Provider = SQLOLEDB添加到您的连接字符串并删除

Driver = {SQL Server}。


出于某种原因,您将参数括在

存储过程。在Transact-SQL中,括号用于分隔

标识符;这是为了允许你有表格和列名称

特殊字符,例如空格。因此,在这种情况下,你的参数

被解析为标识符,显然它们中的至少一个更长

而不是128,这是优化器的最大长度。 />

除非你有特殊的东西,否则你应该使用''来划定

参数,但不要急于改变这一点,而是继续阅读。你没有
不能将用户输入直接传递给这样的SQL字符串。假设你实际上用单引号代替括号
。然后说,

用户输入带有单引号的数据。结果:语法

错误。也许。恶意用户可以使用它来输入完全不同于您预期的SQL命令。因此,你有一个很大的安全空间
洞。而且,不,不要笑。 SQL注入是一种非常常见的攻击手段

今天在网上。


一个简单的方法是通过一个双重的过程运行输入/>
输入中的所有单引号。也就是说,如果用户输入O''Brien,则

你传递O,Brien。到SQL Server。然后将其解析为O''Brien。

然而,更好的方法是使用命令类型adStoredProcedure和

通过.Parameters集合传递参数值。然后你

不必费心去引用或包围或任何东西。这是一个更有效的方式来调用存储过程。


-

Erland Sommarskog,SQL Server MVP, es****@sommarskog.se


SQL Server SP3联机丛书
http://www.microsoft。 com / sql / techinf ... 2000 / books.asp




" Erland Sommarskog" schrieb

"Erland Sommarskog" schrieb
在我解决实际问题之前,请允许我指出您使用MSDASQL提供程序,OLE DB over ODBC。请改用SQLOLEDB提供程序,因为此提供程序直接针对SQL Server而且更有效。将Provider = SQLOLEDB添加到您的连接字符串并删除
Driver = {SQL Server}。
Before I address you actual problem, permit me to point out that you are
using the MSDASQL provider, OLE DB over ODBC. Use the SQLOLEDB provider
instead, since this provider is directly targeted for SQL Server and more
effecient. Add Provider=SQLOLEDB to your connection string and remove
Driver={SQL Server}.




您有一个特殊的网页来阅读它们之间的差异这两种方法?

我试图通过查询分析器发出一个简单的SQL请求,如下所示:



You''ve got a special Webpage to read the differences between this two methods?
I tried to make a simple SQL request via Query Analyzer, like this:

展开 | 选择 | 换行 | 行号


你正在使用双引号。您需要使用单引号。双引号是

用于括号等标识符。


-

David Gugick

Imceda Software
You''re using double quotes. You need to use single quotes. Double quotes are
used for identifiers like brackets are.

--
David Gugick
Imceda Software


这篇关于解决程序的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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