Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
This problem is creating when i Insert data SQL server with store procedure first time insert successfully but second time problem is create .
The problem is Procedure or function spUpdateDomain has too many arguments specified
my code is.
 
C# Code is
 
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "spcontactInsert";
cmd.Parameters.AddWithValue("@ContactName ", UserName.Text);
cmd.Parameters.AddWithValue("@ContactAddress ", Address.Text);
cmd.Parameters.AddWithValue("@ContactEmail  ", email);
cmd.Parameters.AddWithValue("@PhoneNumber  ", phone);
cmd.Parameters.AddWithValue("@FirstMobNumber  ", FirstNumber.Text);
cmd.Parameters.AddWithValue("@SecondMobNumber  ", SecendNumber.Text);
cmd.Parameters.AddWithValue("@ThirdMobNumber  ", txt.Text);
con.Open();
cmd.Connection = con;
int i = cmd.ExecuteNonQuery();
con.Close();
 

SQL Store Procedure Code
 
ALTER PROCEDURE [dbo].[spcontactInsert]
@ContactName nvarchar(50),
@ContactAddress nvarchar(50),
@ContactEmail nvarchar(50),
@PhoneNumber nvarchar(50),
@FirstMobNumber bigint,
@SecondMobNumber bigint,
@ThirdMobNumber bigint
AS
BEGIN
if not exists(Select FirstMobNumber from ContactDB where FirstMobNumber=@FirstMobNumber)
begin
INSERT INTO ContactDB(ContactName, ContactAddress, ContactEmail,PhoneNumber,FirstMobNumber, SecondMobNumber, ThirdMobNumber)
VALUES (@ContactName,@ContactAddress,@ContactEmail,@PhoneNumber,@FirstMobNumber,@SecondMobNumber,@ThirdMobNumber)
end
END
 

 

 
Pleease solve my problem
Posted 4-Apr-13 0:36am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I guess your parameters are not being cleared. Add this line just before adding the parameters:
cmd.Parameters.Clear();
If this doesn't solve your problem, use an SQL Profiler[^] to see what query exactly is passed to SQL. Try and execute that on SQL Query Analyzer.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Mathew Soji 334
1 Maciej Los 295
2 BillWoodruff 290
3 Afzaal Ahmad Zeeshan 257
4 DamithSL 225
0 OriginalGriff 6,369
1 Sergey Alexandrovich Kryukov 5,973
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 4,045


Advertise | Privacy | Mobile
Web04 | 2.8.1411019.1 | Last Updated 4 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100