问题描述
您好,有没有人在此之前遇到此错误?在我向表中添加一列后,然后更新存储过程,然后重新编译该站点,同时,我收到此错误消息。以下是堆栈跟踪。有没有人可以提供帮助?
程序或函数'spInsertOrganization'需要参数'@nconnectionType',这是未提供的。
异常详细信息:System.Data.SqlClient.SqlException:过程或函数'spInsertOrganization'需要参数'@nconnectionType',这是未提供的。
源错误:
第92行:command.Parameters.Add(new SqlParameter(networkAvailability,organization.NetworkAvailability));
Line 93:command.Parameters.Add(new SqlParameter(nconnectionType,organization.NConnectionType));
第94行:command.ExecuteNonQuery();
第95行:}
第96行:}
Stack Trace:
Hello, does anyone face this error before? After I add one more column to the table, then update the store procedure, then I recompile the site, Meanwhile, I got this error message. The following are the stack trace. Does anyone can help?
Procedure or function 'spInsertOrganization' expects parameter '@nconnectionType', which was not supplied.
Exception Details: System.Data.SqlClient.SqlException: Procedure or Function 'spInsertOrganization' expects parameter '@nconnectionType', which was not supplied.
Source Error:
Line 92: command.Parameters.Add(new SqlParameter("networkAvailability", organization.NetworkAvailability));
Line 93: command.Parameters.Add(new SqlParameter("nconnectionType", organization.NConnectionType));
Line 94: command.ExecuteNonQuery();
Line 95: }
Line 96: }
Stack Trace:
[SqlException (0x80131904): Procedure or function 'spInsertOrganization' expects parameter '@nconnectionType', which was not supplied.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +1753986
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5296058
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +558
System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +1682
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +269
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite) +1379
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite) +175
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) +205
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +160
MMSDataAccessLayer.OrganizationDAL.InsertOrganization(Organization organization) in D:\backup files sqlserver\material management new latest\Materials Management System Backup\MMSDataAccessLayer\OrganizationDAL.cs:94
RegionalDataOperator_Organization.btnAddOrganization_Click(Object sender, EventArgs e) in d:\backup files sqlserver\material management new latest\Materials Management System Backup\MMSUI\RegionalDataOperator\Organization.aspx.cs:197
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9552602
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724
我的程序:
My sotored Procedure:
public void InsertOrganization(Organization organization)
{
using (SqlConnection _connection = new SqlConnection(this._connectionString))
{
_connection.Open();
using (SqlCommand command = _connection.CreateCommand())
{
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "spInsertOrganization";
command.Parameters.Add(new SqlParameter("organizationName", organization.OrganizationName));
command.Parameters.Add(new SqlParameter("authority", organization.Authority));
command.Parameters.Add(new SqlParameter("typeOfOrganization", organization.TypeOfOrganization ));
command.Parameters.Add(new SqlParameter("phoneNumber", organization.PhoneNumber));
command.Parameters.Add(new SqlParameter("phoneNumber2", organization.PhoneNumberTwo));
command.Parameters.Add(new SqlParameter("fax", organization .Fax));
command.Parameters.Add(new SqlParameter("organizationSector", organization.OrganizationSector));
command.Parameters.Add(new SqlParameter("woredaID", organization.WoredaID));
command.Parameters.Add(new SqlParameter("zoneID", organization.ZoneID));
command.Parameters.Add(new SqlParameter("websiteURL", organization.WebsiteURL));
command.Parameters.Add(new SqlParameter("internetAvailability", organization.NetworkAvailability));
command.Parameters.Add(new SqlParameter("connectionType", organization.ConnectionType));
command.Parameters.Add(new SqlParameter("networkAvailability",organization.NetworkAvailability));
command.Parameters.Add(new SqlParameter("nconnectionType", organization.NConnectionType));
command.ExecuteNonQuery();
}
}
}
推荐答案
command.Parameters.Add(new SqlParameter("@nconnectionType", organization.NConnectionType));
并确保您提供的值不为空。
And make sure that the value you are supplying is not null.
// This is my code
public static DataTable getOutput(string str)
{
SqlConnection con = Connection.getConnection();
SqlDataAdapter adapter = new SqlDataAdapter(str,con);
SqlCommand sqlCmd = new SqlCommand(str,con);
sqlCmd.CommandText = "sp_CheckMobiles_number";
sqlCmd.CommandType = CommandType.StoredProcedure;
sqlCmd.Parameters.AddWithValue("@mobile",SqlDbType.BigInt).Value=112233;
DataSet version = new DataSet();
adapter.Fill(version);
DataTable dt = version.Tables[0];
return dt;
}
//This is my stored procedure
create PROCEDURE [dbo].[sp_CheckMobiles_number]
@mobile BIGINT
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Exists BIGINT
IF EXISTS( select dbo.[user].PKID, dbo.[user].USER_ID, dbo.[user].NAME, dbo.[user].MOBILE, dbo.[user].COUNTRY_CODE, dbo.[user].IS_ENABLED, dbo.[user].TYPE,
dbo.[user].STATUS, dbo.[order].OID, dbo.[order].ORDERID, dbo.[order].PKID AS PKID, dbo.[order].DRIVER_PKID, dbo.[order].SCH_DATE, dbo.[order].FROM_ADDR,
dbo.[order].TO_ADDR, dbo.[order].PAY_TYPE, dbo.[order].STATUS AS Status
FROM dbo.[user] left JOIN
dbo.[order] ON dbo.[user].pkid = dbo.[order].PKID
where dbo.[order].STATUS='fin''can' and dbo.[user].MOBILE=112233)
BEGIN
SET @Exists = @mobile
END
ELSE
BEGIN
SET @Exists = 0
END
RETURN @mobile
END
DECLARE @ReturnValue bigint
EXEC @ReturnValue = sp_CheckMobiles_number 112233
SELECT @ReturnValue
这篇关于过程或函数需要未提供的参数。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!