我有一个简单的表,其中包含三个字段:
ID (int)
FormData (xml)
TimeStamp (DateTime).
我创建了一个存储过程来将值插入成功运行的表中。但是,在我的尝试捕获中,它正在捕获
System.Data.SqlClient.SqlException:过程或函数“spInsertApplication”需要参数“@formDataDecoded”,但未提供该参数。
但是,@formDataDecoded 参数被很好地插入到数据库中。
有任何想法吗?我不知道从这里去哪里?
这是存储过程:
ALTER PROCEDURE [dbo].[spInsertApplication]
-- Add the parameters for the stored procedure here
@formDataDecoded xml,
@timestamp DateTime
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
INSERT INTO Applications (formXML, TimeStamp) VALUES (@formDataDecoded, @timestamp)
END
这是c#:
string con = ConfigurationManager.AppSettings["umbracoDbDSN"];
using (SqlConnection connection = new SqlConnection(con))
{
String encodedFormData = HttpUtility.UrlDecode(formData);
SqlCommand command = connection.CreateCommand();
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "spInsertApplication";
command.Parameters.AddWithValue("@formDataDecoded", encodedFormData);
command.Parameters.AddWithValue("@timestamp", DateTime.Now);
try
{
connection.Open();
command.ExecuteNonQuery();
}
catch (Exception ex)
{
String errorSql = "INSERT INTO ErrorLog(ErrorText) VALUES (@errorText)";
SqlCommand errorCommand = new SqlCommand(errorSql, connection);
errorCommand.Parameters.AddWithValue("@errorText", ex.ToString());
errorCommand.ExecuteNonQuery();
Response.Redirect("/enterprise-superstars/sounds-like-you-are-already-a-star.aspx");
}
finally
{
connection.Close();
}
}
我得到这样的formData:
String formData = Request.Form["xmlToVar"];
我将其传递给 saveApplicationform 方法。
提前致谢。
编辑
在上面运行 SQL Server Profiler 跟踪,结果发现存储过程被调用了两次。
事情是一个闪存表单调用特定页面,我将不得不让某人查看闪存代码并查看它是如何发布的,因为我没有编写它。