Procedure or function expects parameter that was not supplied why it arise and if arise how to resolve it
-
Procedure or function expects parameter that was not supplied why it arise and if arise how to resolve it
Supply the expected parameter. Given that you have not shown the line of code in question we have no way of knowing the answer. If it's a call to a system API method then take a look at the documentation to find out why. If it is code belonging to some other developer then ask them.
-
Procedure or function expects parameter that was not supplied why it arise and if arise how to resolve it
-
Supply the expected parameter. Given that you have not shown the line of code in question we have no way of knowing the answer. If it's a call to a system API method then take a look at the documentation to find out why. If it is code belonging to some other developer then ask them.
OK I am supplying my code with stored proc here: My stored proc: USE [UniqueCorp] GO /****** Object: StoredProcedure [dbo].[uspUpdateUser_Step2] Script Date: 06/05/2012 12:12:38 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[uspUpdateUser_Step2] @userID uniqueidentifier, @Username nvarchar(50), @CompanyName nvarchar(50), @Address nvarchar(100), @Country nvarchar(50), @State nvarchar(50) = '', @City nvarchar(50) = '', @MobileNo nvarchar(50) = '', @TelephoneNo nvarchar(50) = '', @Password nvarchar(50) AS set nocount on; IF Exists (SELECT [ID] FROM dbo.Users WHERE [ID] = @userID) begin update dbo.Users set UserName=@Username, CompanyName=@CompanyName, [Address]=@Address, Country=@Country, [State]=@State, City=@City, Mobileno=@MobileNo, TelephoneNo=@TelephoneNo, Password=@Password WHERE [ID] = @userID end GO and the code behind is this....... public static int AddUpdateUser(Users user) { SqlParameter prmUserId = new SqlParameter("@userID", SqlDbType.UniqueIdentifier); prmUserId.Value = user.ID; SqlParameter prmUsername = new SqlParameter("@Username", SqlDbType.NVarChar, 50); prmUsername.Value = user.UserName; SqlParameter prmCompanyName = new SqlParameter("@CompanyName", SqlDbType.NVarChar, 50); prmUsername.Value = user.CompanyName; SqlParameter prmAddress = new SqlParameter("@Address", SqlDbType.NVarChar, 100); prmUsername.Value = user.Address; SqlParameter prmCountry = new SqlParameter("@Country", SqlDbType.NVarChar, 50); prmUsername.Value = user.Country; SqlParameter prmState = new SqlParameter("@State", SqlDbType.NVarChar, 50); prmUsername.Value = user.State; SqlParameter prmCity = new SqlParameter("@City", SqlDbType.NVarChar, 50); prmUsername.Value = user.City; SqlParameter prmMobileNo = new SqlParameter("@MobileNo", SqlDbType.Int, 50); prmUsername.Value = user.MobileNo; SqlParameter prmTelephoneNo = new SqlParameter("@TelephoneNo", SqlDbType.Int, 50); prmUsername.Value = user.TelephoneNo; SqlParameter prmPassword = new SqlParameter("@Password", SqlDbType.NVarChar, 50); prmUsername.Value = user.Password; return DataAccessObject.Execute("uspUpdateUser_Step2",prmUserId, prmUsername
-
That sounds like a sql parameter your supplying is null, empty or nothing. where @value is empty.
value=@value,
But like Richard said, you should walk your code, or show some code so we know what your taking about, or just Google it.
OK I am supplying my code with stored proc here: My stored proc: USE [UniqueCorp] GO /****** Object: StoredProcedure [dbo].[uspUpdateUser_Step2] Script Date: 06/05/2012 12:12:38 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[uspUpdateUser_Step2] @userID uniqueidentifier, @Username nvarchar(50), @CompanyName nvarchar(50), @Address nvarchar(100), @Country nvarchar(50), @State nvarchar(50) = '', @City nvarchar(50) = '', @MobileNo nvarchar(50) = '', @TelephoneNo nvarchar(50) = '', @Password nvarchar(50) AS set nocount on; IF Exists (SELECT [ID] FROM dbo.Users WHERE [ID] = @userID) begin update dbo.Users set UserName=@Username, CompanyName=@CompanyName, [Address]=@Address, Country=@Country, [State]=@State, City=@City, Mobileno=@MobileNo, TelephoneNo=@TelephoneNo, Password=@Password WHERE [ID] = @userID end GO and the code behind is this....... public static int AddUpdateUser(Users user) { SqlParameter prmUserId = new SqlParameter("@userID", SqlDbType.UniqueIdentifier); prmUserId.Value = user.ID; SqlParameter prmUsername = new SqlParameter("@Username", SqlDbType.NVarChar, 50); prmUsername.Value = user.UserName; SqlParameter prmCompanyName = new SqlParameter("@CompanyName", SqlDbType.NVarChar, 50); prmUsername.Value = user.CompanyName; SqlParameter prmAddress = new SqlParameter("@Address", SqlDbType.NVarChar, 100); prmUsername.Value = user.Address; SqlParameter prmCountry = new SqlParameter("@Country", SqlDbType.NVarChar, 50); prmUsername.Value = user.Country; SqlParameter prmState = new SqlParameter("@State", SqlDbType.NVarChar, 50); prmUsername.Value = user.State; SqlParameter prmCity = new SqlParameter("@City", SqlDbType.NVarChar, 50); prmUsername.Value = user.City; SqlParameter prmMobileNo = new SqlParameter("@MobileNo", SqlDbType.Int, 50); prmUsername.Value = user.MobileNo; SqlParameter prmTelephoneNo = new SqlParameter("@TelephoneNo", SqlDbType.Int, 50); prmUsername.Value = user.TelephoneNo; SqlParameter prmPassword = new SqlParameter("@Password", SqlDbType.NVarChar, 50); prmUsername.Value = user.Password; return DataAccessObject.Execute("uspUpdateUser_Step2",prmUserId, prmUsername, prmCompanyName, prmAddress, prmCountry, prmState, prmCity, prmMobileNo, prmTelephoneNo,prmPassword); } Please help me the problem is still there... Procedure or function expects parameter @Username That was not supplied..... But i debug and confirm dat value is
-
Supply the expected parameter. Given that you have not shown the line of code in question we have no way of knowing the answer. If it's a call to a system API method then take a look at the documentation to find out why. If it is code belonging to some other developer then ask them.
we have to assign default value as NULL Create Procedure Sp_name @Input1 varchar(100)=NULL AS BEGIn //main Code END
-
Procedure or function expects parameter that was not supplied why it arise and if arise how to resolve it
The function or the Procedure is having some Parameters that are not been provided by your code while making call to that procedure. Note: Signature of Fucntion/Procedure while Defining and While Declaring the fucntion donot matches.
- Happy Coding - Vishal Vashishta
-
OK I am supplying my code with stored proc here: My stored proc: USE [UniqueCorp] GO /****** Object: StoredProcedure [dbo].[uspUpdateUser_Step2] Script Date: 06/05/2012 12:12:38 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[uspUpdateUser_Step2] @userID uniqueidentifier, @Username nvarchar(50), @CompanyName nvarchar(50), @Address nvarchar(100), @Country nvarchar(50), @State nvarchar(50) = '', @City nvarchar(50) = '', @MobileNo nvarchar(50) = '', @TelephoneNo nvarchar(50) = '', @Password nvarchar(50) AS set nocount on; IF Exists (SELECT [ID] FROM dbo.Users WHERE [ID] = @userID) begin update dbo.Users set UserName=@Username, CompanyName=@CompanyName, [Address]=@Address, Country=@Country, [State]=@State, City=@City, Mobileno=@MobileNo, TelephoneNo=@TelephoneNo, Password=@Password WHERE [ID] = @userID end GO and the code behind is this....... public static int AddUpdateUser(Users user) { SqlParameter prmUserId = new SqlParameter("@userID", SqlDbType.UniqueIdentifier); prmUserId.Value = user.ID; SqlParameter prmUsername = new SqlParameter("@Username", SqlDbType.NVarChar, 50); prmUsername.Value = user.UserName; SqlParameter prmCompanyName = new SqlParameter("@CompanyName", SqlDbType.NVarChar, 50); prmUsername.Value = user.CompanyName; SqlParameter prmAddress = new SqlParameter("@Address", SqlDbType.NVarChar, 100); prmUsername.Value = user.Address; SqlParameter prmCountry = new SqlParameter("@Country", SqlDbType.NVarChar, 50); prmUsername.Value = user.Country; SqlParameter prmState = new SqlParameter("@State", SqlDbType.NVarChar, 50); prmUsername.Value = user.State; SqlParameter prmCity = new SqlParameter("@City", SqlDbType.NVarChar, 50); prmUsername.Value = user.City; SqlParameter prmMobileNo = new SqlParameter("@MobileNo", SqlDbType.Int, 50); prmUsername.Value = user.MobileNo; SqlParameter prmTelephoneNo = new SqlParameter("@TelephoneNo", SqlDbType.Int, 50); prmUsername.Value = user.TelephoneNo; SqlParameter prmPassword = new SqlParameter("@Password", SqlDbType.NVarChar, 50); prmUsername.Value = user.Password; return DataAccessObject.Execute("uspUpdateUser_Step2",prmUserId, prmUsername
Firstly, this is a database problem and nothing to do with ASP.NET, so it is in the wrong forum. Secondly, you have given no indication where the error occurs. Thirdly, please use the correct <pre> tags around your code so it is readable, like this:
USE [UniqueCorp]
GO/****** Object: StoredProcedure [dbo].[uspUpdateUser_Step2] Script Date: 06/05/2012 12:12:38 ******/
SET ANSI_NULLS ON
GO...
-
OK I am supplying my code with stored proc here: My stored proc: USE [UniqueCorp] GO /****** Object: StoredProcedure [dbo].[uspUpdateUser_Step2] Script Date: 06/05/2012 12:12:38 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[uspUpdateUser_Step2] @userID uniqueidentifier, @Username nvarchar(50), @CompanyName nvarchar(50), @Address nvarchar(100), @Country nvarchar(50), @State nvarchar(50) = '', @City nvarchar(50) = '', @MobileNo nvarchar(50) = '', @TelephoneNo nvarchar(50) = '', @Password nvarchar(50) AS set nocount on; IF Exists (SELECT [ID] FROM dbo.Users WHERE [ID] = @userID) begin update dbo.Users set UserName=@Username, CompanyName=@CompanyName, [Address]=@Address, Country=@Country, [State]=@State, City=@City, Mobileno=@MobileNo, TelephoneNo=@TelephoneNo, Password=@Password WHERE [ID] = @userID end GO and the code behind is this....... public static int AddUpdateUser(Users user) { SqlParameter prmUserId = new SqlParameter("@userID", SqlDbType.UniqueIdentifier); prmUserId.Value = user.ID; SqlParameter prmUsername = new SqlParameter("@Username", SqlDbType.NVarChar, 50); prmUsername.Value = user.UserName; SqlParameter prmCompanyName = new SqlParameter("@CompanyName", SqlDbType.NVarChar, 50); prmUsername.Value = user.CompanyName; SqlParameter prmAddress = new SqlParameter("@Address", SqlDbType.NVarChar, 100); prmUsername.Value = user.Address; SqlParameter prmCountry = new SqlParameter("@Country", SqlDbType.NVarChar, 50); prmUsername.Value = user.Country; SqlParameter prmState = new SqlParameter("@State", SqlDbType.NVarChar, 50); prmUsername.Value = user.State; SqlParameter prmCity = new SqlParameter("@City", SqlDbType.NVarChar, 50); prmUsername.Value = user.City; SqlParameter prmMobileNo = new SqlParameter("@MobileNo", SqlDbType.Int, 50); prmUsername.Value = user.MobileNo; SqlParameter prmTelephoneNo = new SqlParameter("@TelephoneNo", SqlDbType.Int, 50); prmUsername.Value = user.TelephoneNo; SqlParameter prmPassword = new SqlParameter("@Password", SqlDbType.NVarChar, 50); prmUsername.Value = user.Password; return DataAccessObject.Execute("uspUpdateUser_Step2",prmUserId, prmUsername, prmCompanyName, prmAddress, prmCountry, prmState, prmCity, prmMobileNo, prmTelephoneNo,prmPassword); } Please help me the problem is still there... Procedure or function expects parameter @Username That was not supplied..... But i debug and confirm dat value is
I'm just using this one as an example only, it's not the problem. The error message you got basically says that one of your parameters is null or nothing, and that a valid value is required in order to convert the value to a qualified parameter.
prmUsername.Value = user.Address; <- One of these values is null or nothing in your list of parameters, or is the wrong format for nvarchar.
If you wrap your code in the try, catch, you can trap the sql exception message, and it will tell you which parameter is the issue. catch ex as sqlexception