我收到了这个错误,你能帮帮我吗?提前谢谢
过程或函数'ACMS_add'需要参数'@ACMS_doc_name',这是未提供的。
类
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 !!! ";
}
}
答案 0 :(得分:5)
在初始化所有属性后,您应该调用您的方法:
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;
和last(因为它正在执行存储过程):
acmsAdd.ACMS_add(Page.User.Identity.Name);
更好的方法是更改方法的签名,以便必须提供所有参数。
答案 1 :(得分:2)
在您的程序代码中,您有以下内容.....
@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)
现在我不是C#的用户,但我注意到你的doc_file_name和其他一些行中没有“AS”子句......
你认为这可能是问题吗?