gpt4 book ai didi

c# - 过程或函数 'ACMS_add' 需要参数 '@ACMS_doc_nane',但未提供

转载 作者:太空宇宙 更新时间:2023-11-03 18:36:40 26 4
gpt4 key购买 nike

我遇到了这个错误,你能帮我吗?提前致谢

Procedure or function 'ACMS_add' expects parameter '@ACMS_doc_name', which was not supplied.

public bool ACMS_add( string ENTRYUSER)
{
bool status = false;
ACMS_core.settings.ACMS_global_settings Conn = new ACMS_core.settings.ACMS_global_settings();

SqlConnection conn = new SqlConnection(Conn.myConnectionString());
SqlCommand cmd = new SqlCommand("ACMS_add", conn);
cmd.CommandType = CommandType.StoredProcedure;

cmd.Parameters.Add("@ACMS_Number", SqlDbType.NVarChar).Value = ACMS_Number;
//cmd.Parameters.Add("@ACMS_Date", SqlDbType.DateTime).Value = ACMS_Date;
cmd.Parameters.Add("@ACMS_Type", SqlDbType.Int).Value = ACMS_Type;
cmd.Parameters.Add("@enrty_user", SqlDbType.NVarChar).Value = ENTRYUSER;
cmd.Parameters.Add("@ACMS_doc_name", SqlDbType.NVarChar).Value = ACMS_doc_name;
cmd.Parameters.Add("@ACMS_doc_file", SqlDbType.Image).Value = ACMS_doc_file;
cmd.Parameters.Add("@ACMS_doc_ext", SqlDbType.VarChar).Value = ACMS_doc_ext;
cmd.Parameters.Add("@ACMS_doc_mime_type", SqlDbType.VarChar).Value = ACMS_doc_mime_type;

conn.Open();

try
{
cmd.ExecuteNonQuery();
status = true;
}
catch (Exception ex)
{
// return ex.Message;
status = false;
}

conn.Close();
conn.Dispose();

return status;
}

程序

            USE [TaxDisputes]
GO
/****** Object: StoredProcedure [dbo].[ACMS_add] Script Date: 1/11/2013 5:04:01 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- =============================================
ALTER PROCEDURE [dbo].[ACMS_add]


@ACMS_Number as nvarchar (50),
--@ACMS_Date as datetime,
@ACMS_Type as int,
@enrty_user as nvarchar (50),
@ACMS_doc_name nvarchar (250),
@ACMS_doc_file image ,
@ACMS_doc_ext nvarchar(50),
@ACMS_doc_mime_type varchar(250)

AS
BEGIN

SET NOCOUNT ON;
----#
DECLARE @doc_type int

IF exists (select mimetype from dbo.itdc_doc_extenstions where mimetype = @ACMS_doc_mime_type)
BEGIN

SET @doc_type = (select doc_ext_id from dbo.itdc_doc_extenstions where mimetype = @ACMS_doc_mime_type)

END
ELSE

BEGIN
INSERT INTO [dbo].[itdc_doc_extenstions]
(
[doc_ext],
[mimetype]
)
VALUES
(
@ACMS_doc_ext,
@ACMS_doc_mime_type
)
SET @doc_type = @@IDENTITY

END

----#
BEGIN
INSERT INTO [dbo].[itdc_ACMS]
(
[ACMS_Number]
-- ,[ACMS_Date]
,[ACMS_Type]
,[entry_user]
,[ACMS_doc_name]
,[ACMS_doc_file]
)
VALUES

(
@ACMS_Number,
-- @ACMS_Date,
@ACMS_Type,
@enrty_user,
@ACMS_doc_name,
@ACMS_doc_file
)

END
END

代码隐藏

protected void Submitform_Click(object sender, EventArgs e)
{
itdc_core.db_ACMS.acms acmsAdd = new acms();
String fileName = DocUpload.FileName;

if (fileName != "")
{
String file_ext = "";

try
{
file_ext = fileName.Substring(fileName.LastIndexOf("."), fileName.Length - fileName.LastIndexOf("."));
}
catch
{
file_ext = "";
}

try
{
acmsAdd.ACMS_Number = docNumber.Text.Trim();
//acmsAdd.ACMS_Date = Convert.ToDateTime("2013-01-10 19:08:12.300");
acmsAdd.ACMS_Type = Convert.ToInt32(docType.SelectedValue);
acmsAdd.ACMS_add(Page.User.Identity.Name);
acmsAdd.ACMS_doc_name = DocUpload.FileName.ToString();
acmsAdd.ACMS_doc_file = DocUpload.FileBytes;
acmsAdd.ACMS_doc_mime_type = DocUpload.PostedFile.ContentType;
acmsAdd.ACMS_doc_ext = file_ext;

litDeleteDocumentMessage.Text = ("File added succsesfully");
}
catch
{
litDeleteDocumentMessage.Text = "Error !!! try again later";
}
}
else
{
litDeleteDocumentMessage.Text = "Please choose document !!! ";
}
}

enter image description here

最佳答案

您应该在初始化所有属性后调用您的方法:

acmsAdd.ACMS_Number = docNumber.Text.Trim();
//acmsAdd.ACMS_Date = Convert.ToDateTime("2013-01-10 19:08:12.300");
acmsAdd.ACMS_Type = Convert.ToInt32(docType.SelectedValue);
acmsAdd.ACMS_doc_name = DocUpload.FileName.ToString();
acmsAdd.ACMS_doc_file = DocUpload.FileBytes;
acmsAdd.ACMS_doc_mime_type = DocUpload.PostedFile.ContentType;
acmsAdd.ACMS_doc_ext = file_ext;

最后(因为它正在执行存储过程):

acmsAdd.ACMS_add(Page.User.Identity.Name);

更好的方法是更改​​方法的签名,以便必须提供所有参数。

关于c# - 过程或函数 'ACMS_add' 需要参数 '@ACMS_doc_nane',但未提供,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14279143/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com