Click here to Skip to main content
11,495,534 members (63,354 online)
Rate this: bad
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);
cmd.Connection = con;
int i = cmd.ExecuteNonQuery();

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
if not exists(Select FirstMobNumber from ContactDB where FirstMobNumber=@FirstMobNumber)
INSERT INTO ContactDB(ContactName, ContactAddress, ContactEmail,PhoneNumber,FirstMobNumber, SecondMobNumber, ThirdMobNumber)
VALUES (@ContactName,@ContactAddress,@ContactEmail,@PhoneNumber,@FirstMobNumber,@SecondMobNumber,@ThirdMobNumber)

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

1 solution

Rate this: bad
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:
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.

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

  Print Answers RSS
0 Dnyaneshwar@Pune 692
1 CHill60 318
2 Sascha Lefèvre 275
3 Nakul Chaudhari 236
4 Sergey Alexandrovich Kryukov 230
0 Sergey Alexandrovich Kryukov 10,362
1 OriginalGriff 8,821
2 Sascha Lefèvre 3,899
3 Maciej Los 3,422
4 Richard Deeming 2,600

Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 4 Apr 2013
Copyright © CodeProject, 1999-2015
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