You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将textarea数据存入数据库?解决@detail参数未提供异常

Fix: Procedure expects parameter '@detail' which was not supplied

Let's break down and fix this issue quickly:

Root Cause

The error pops up because your code is trying to fetch the textarea's value using the wrong key in Request.Form, which results in a null value being passed to the @detail parameter of your stored procedure. Since the stored procedure requires this parameter, it throws the exception you're seeing.

Step-by-Step Fixes

1. Correct the Request.Form Key

In your Movies.aspx.cs file, you're using Request.Form["txtCommentBox_1"] to get the textarea content, but your textarea's name attribute is txtCommentBox (not txtCommentBox_1).

Change this line:

string text = Request.Form["txtCommentBox_1"];

To this:

// Get the value, default to empty string if it's null
string text = Request.Form["txtCommentBox"] ?? string.Empty;

2. (Optional but Recommended) Use Server-Side Control for Reliability

Instead of relying on Request.Form, convert the textarea to an ASP.NET server control by adding runat="server". This makes accessing its value more straightforward and less error-prone.

Update the textarea in Movies.aspx:

<textarea id="txtCommentBox" name="txtCommentBox" runat="server" rows="6" style="width:340px;" 
onKeyDown="textCounter(this.form.txtCommentBox,this.form.countDisplay);" 
onKeyUp="textCounter(this.form.txtCommentBox,this.form.countDisplay);"></textarea>

Then in Movies.aspx.cs, replace the Request.Form line with:

string text = txtCommentBox.Value ?? string.Empty;

3. Verify Parameter Handling

Ensure that even if the user leaves the textarea empty, you're passing a valid value (not null) to the stored procedure. The ?? string.Empty in the code above ensures this, so the @detail parameter will always receive a valid string (even if it's empty).

Final Check

After making these changes, test the upload functionality again. The @detail parameter will now be properly supplied with the textarea's content (or an empty string if nothing was entered), and the exception should be resolved.

内容的提问来源于stack exchange,提问作者Suhel shaikh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:39:56