检索 NVARCHAR(max) 列时 SqlDataSource 出错
我正在编写一个小型 ASP .Net 应用程序,以便从 SQL 数据库检索数据。应用程序使用下拉列表来选择下一个下拉列表应包含的内容,并且当选择页面时,它应该从数据库中检索 HTML。一切正常,直到检索 HTML 数据为止。当我尝试检索数据时,我得到:
Microsoft JScript 运行时错误: Sys.WebForms.PageRequestManagerServerErrorException: 发生未知错误 在服务器上处理请求。 返回的状态码 服务器为:500
HTML 列定义为 NVARCHAR(MAX)
,但我看不出这会导致问题。如果我将 DataValueField
设置为另一列,则应用程序可以正常工作。还有人遇到过这样的问题吗?也许有人可以对此有所启发?
I'm writing a small ASP .Net application in order to retrieve data from a SQL database. The application uses drop downs in order to select what the next drop down should contain and when a page is selected, it should retrieve the HTML from the database. Everything is working until it gets to the retrival of the HTML data. When I try to retrieve the data, I get:
Microsoft JScript runtime error:
Sys.WebForms.PageRequestManagerServerErrorException:
An unknown error occurred while
processing the request on the server.
The status code returned from the
server was: 500
The HTML column is a defined as NVARCHAR(MAX)
, but I can't see this causing a problem. The application works if I set the DataValueField
to another column. Has one else come across a problem like this? Maybe someone could shine some light on this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在处理 varchar(max) 列时注意到的一件事是,框架通常仍然期望有一个与之关联的大小。我最终要做的是将长度指定为 -1 以使其接受 varchar(max) 字段。您的错误消息并不表明这就是问题所在,但您可以尝试尝试一下,而不是关闭验证,这可能会产生其他影响。
One thing I noted when dealing with varchar(max) columns is that the framework still commonly expects to have a size associated with it. What I ended up having to do was specify the length as -1 to get it to accept a varchar(max) field. Your error message doesn't indicate that this is the problem, but you might try experimenting with it rather than turning off the validation, which could possibly have other repercussions.
想通了。只需在
Page
级别将ValidateRequest
设置为false
即可。Figured it out. Just needed to set
ValidateRequest
tofalse
at thePage
level.