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 OriginalGriff 406
1 /\jmot 180
2 Suraj Sahoo | Coding Passion 170
3 BillWoodruff 159
4 Afzaal Ahmad Zeeshan 154
0 OriginalGriff 8,344
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,634
3 Maciej Los 5,024
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.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