473,372 Members | 995 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

STRANGE PROBLEM

Im getting that error (It is strange. I Run my programme step by step
pressing f11. im looping SqlCommand in a while loop. The First step runs but
when a enter 2nd step in my loop it returns error ? )

any idea ?

System.Data.SqlClient.SqlException: Procedure or function sp_adduser has
too many arguments specified

My Stored Procedure

CREATE PROCEDURE ST_BOTMARKA
@SiteID INT,
@Marka NVARCHAR (255),
@MarkaLink NVARCHAR (500),
@Tarih NVARCHAR (300)
AS

IF Exists( SELECT 1 FROM TBL_BOTMARKALAR Where MarkaAdi=@Marka AND
SiteID=@SiteID)
UPDATE TBL_BOTMARKALAR SET MarkaLink=@MarkaLink,Tarih=@Tarih
ELSE
INSERT INTO TBL_BOTMARKALAR (SiteID,MarkaAdi,MarkaLink,Tarih) Values
(@SiteID,@Marka,@MarkaLink,@Tarih)
GO


con.ConnectionString = "Initial Catalog=saat;User
Id=sates52;password=abc;Data Source=127.0.0.1";

Today = ConvertDateFunction(System.DateTime.Now);

while (true)

{

con.Open ();

cmd.Connection =con;

cmd.CommandType =CommandType.StoredProcedure;

cmd.CommandText ="ST_BOTMARKA";

cmd.Parameters.Add ("@SiteID",SqlDbType.Int).Value=1;

cmd.Parameters.Add ("@Marka",SqlDbType.NVarChar).Value=Marka;

cmd.Parameters.Add ("@MarkaLink",SqlDbType.NVarChar).Value=MarkaLi nk;

cmd.Parameters.Add ("@Tarih",SqlDbType.NVarChar).Value=Today;

try

{

cmd.ExecuteNonQuery ();

}

catch (Exception e)

{

MessageBox.Show (e.ToString());

}

cmd.Dispose();

con.Close();

}
Jan 29 '07 #1
4 1349
Are you re-using a command without Clear()ing the parameters first?
Alternatively, if performing the same command with different
parameter-values, then add them *once* at the top, and then in the
loop just update the values of each parameter as required.

Marc
Jan 29 '07 #2
Thank you for your reply

I used
cmd.Dispose();
hoping to clear all data which cmd object is keeping.

I used
cmd.Parameters.Clear ();

and it worked.
<in da club>, haber iletisinde şunları
yazdı:Ou*************@TK2MSFTNGP05.phx.gbl...
Im getting that error (It is strange. I Run my programme step by step
pressing f11. im looping SqlCommand in a while loop. The First step runs
but when a enter 2nd step in my loop it returns error ? )

any idea ?

System.Data.SqlClient.SqlException: Procedure or function sp_adduser has
too many arguments specified

My Stored Procedure

CREATE PROCEDURE ST_BOTMARKA
@SiteID INT,
@Marka NVARCHAR (255),
@MarkaLink NVARCHAR (500),
@Tarih NVARCHAR (300)
AS

IF Exists( SELECT 1 FROM TBL_BOTMARKALAR Where MarkaAdi=@Marka AND
SiteID=@SiteID)
UPDATE TBL_BOTMARKALAR SET MarkaLink=@MarkaLink,Tarih=@Tarih
ELSE
INSERT INTO TBL_BOTMARKALAR (SiteID,MarkaAdi,MarkaLink,Tarih) Values
(@SiteID,@Marka,@MarkaLink,@Tarih)
GO


con.ConnectionString = "Initial Catalog=saat;User
Id=sates52;password=abc;Data Source=127.0.0.1";

Today = ConvertDateFunction(System.DateTime.Now);

while (true)

{

con.Open ();

cmd.Connection =con;

cmd.CommandType =CommandType.StoredProcedure;

cmd.CommandText ="ST_BOTMARKA";

cmd.Parameters.Add ("@SiteID",SqlDbType.Int).Value=1;

cmd.Parameters.Add ("@Marka",SqlDbType.NVarChar).Value=Marka;

cmd.Parameters.Add ("@MarkaLink",SqlDbType.NVarChar).Value=MarkaLi nk;

cmd.Parameters.Add ("@Tarih",SqlDbType.NVarChar).Value=Today;

try

{

cmd.ExecuteNonQuery ();

}

catch (Exception e)

{

MessageBox.Show (e.ToString());

}

cmd.Dispose();

con.Close();

}


Jan 29 '07 #3

>Im getting that error (It is strange. I Run my programme step by step
pressing f11. im looping SqlCommand in a while loop. The First step runs but
when a enter 2nd step in my loop it returns error ? )

any idea ?

System.Data.SqlClient.SqlException: Procedure or function sp_adduser has
too many arguments specified

My Stored Procedure

CREATE PROCEDURE ST_BOTMARKA
@SiteID INT,
@Marka NVARCHAR (255),
@MarkaLink NVARCHAR (500),
@Tarih NVARCHAR (300)
AS

IF Exists( SELECT 1 FROM TBL_BOTMARKALAR Where MarkaAdi=@Marka AND
SiteID=@SiteID)
UPDATE TBL_BOTMARKALAR SET MarkaLink=@MarkaLink,Tarih=@Tarih
ELSE
INSERT INTO TBL_BOTMARKALAR (SiteID,MarkaAdi,MarkaLink,Tarih) Values
(@SiteID,@Marka,@MarkaLink,@Tarih)
GO


con.ConnectionString = "Initial Catalog=saat;User
Id=sates52;password=abc;Data Source=127.0.0.1";

Today = ConvertDateFunction(System.DateTime.Now);

while (true)

{

con.Open ();

cmd.Connection =con;

cmd.CommandType =CommandType.StoredProcedure;

cmd.CommandText ="ST_BOTMARKA";

cmd.Parameters.Add ("@SiteID",SqlDbType.Int).Value=1;

cmd.Parameters.Add ("@Marka",SqlDbType.NVarChar).Value=Marka;

cmd.Parameters.Add ("@MarkaLink",SqlDbType.NVarChar).Value=MarkaLi nk;

cmd.Parameters.Add ("@Tarih",SqlDbType.NVarChar).Value=Today;

try

{

cmd.ExecuteNonQuery ();

}

catch (Exception e)

{

MessageBox.Show (e.ToString());

}

cmd.Dispose();

con.Close();

}

You add parameters to the stored procedure in a loop.So u add the parameters while true.You should not add parameters in a loop

___
Newsgroups brought to you courtesy of www.dotnetjohn.com
Feb 1 '07 #4
Encik,

At the first place I do not think you should use while (true). What is the
reason you use while (true) ? It is damn bad practise lah encik.

You memang perlu pakai condition lah

chanmm

"kmitzu" <pr********@yahoo.comwrote in message
news:eb**************@TK2MSFTNGP06.phx.gbl...
>
>>Im getting that error (It is strange. I Run my programme step by step
pressing f11. im looping SqlCommand in a while loop. The First step runs
but
when a enter 2nd step in my loop it returns error ? )

any idea ?

System.Data.SqlClient.SqlException: Procedure or function sp_adduser has
too many arguments specified

My Stored Procedure

CREATE PROCEDURE ST_BOTMARKA
@SiteID INT,
@Marka NVARCHAR (255),
@MarkaLink NVARCHAR (500),
@Tarih NVARCHAR (300)
AS

IF Exists( SELECT 1 FROM TBL_BOTMARKALAR Where MarkaAdi=@Marka AND
SiteID=@SiteID)
UPDATE TBL_BOTMARKALAR SET MarkaLink=@MarkaLink,Tarih=@Tarih
ELSE
INSERT INTO TBL_BOTMARKALAR (SiteID,MarkaAdi,MarkaLink,Tarih) Values
(@SiteID,@Marka,@MarkaLink,@Tarih)
GO


con.ConnectionString = "Initial Catalog=saat;User
Id=sates52;password=abc;Data Source=127.0.0.1";

Today = ConvertDateFunction(System.DateTime.Now);

while (true)

{

con.Open ();

cmd.Connection =con;

cmd.CommandType =CommandType.StoredProcedure;

cmd.CommandText ="ST_BOTMARKA";

cmd.Parameters.Add ("@SiteID",SqlDbType.Int).Value=1;

cmd.Parameters.Add ("@Marka",SqlDbType.NVarChar).Value=Marka;

cmd.Parameters.Add ("@MarkaLink",SqlDbType.NVarChar).Value=MarkaLi nk;

cmd.Parameters.Add ("@Tarih",SqlDbType.NVarChar).Value=Today;

try

{

cmd.ExecuteNonQuery ();

}

catch (Exception e)

{

MessageBox.Show (e.ToString());

}

cmd.Dispose();

con.Close();

}

You add parameters to the stored procedure in a loop.So u add the
parameters while true.You should not add parameters in a loop

___
Newsgroups brought to you courtesy of www.dotnetjohn.com
Feb 3 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Rob Ristroph | last post by:
Hi, It's pretty unhelpful to post "I have a huge piece of code that crashes in strange places, what's the problem?" but that's basically my problem and I really am at my wit's end. The piece...
2
by: Paul Drummond | last post by:
Hi all, I am developing software for Linux Redhat9 and I have noticed some very strange behaviour when throwing exceptions within a shared library. All our exceptions are derived from...
25
by: Neil Ginsberg | last post by:
I have a strange situation with my Access 2000 database. I have code in the database which has worked fine for years, and now all of a sudden doesn't work fine on one or two of my client's...
2
by: TB | last post by:
I am seeing a very strange problem as follows... I have a loop where a fair amount of processing is going on and near the top of the loop I access a class that has only static helper functions...
1
by: Sam Kong | last post by:
Hello! Recently I had a strange problem with Visual C# 2005 beta 1. When I ran(F5 key) a program, <#if DEBUG> statement was not working. It ran as RELEASE mode. So I had to manually define...
8
by: Spam Trap | last post by:
I am getting strange resizing problems when using an inherited form. Controls are moving themselves seemingly randomly, but reproducibly. "frmBase" is my base class (a windows form), and...
11
by: Martin Joergensen | last post by:
Hi, I've encountered a really, *really*, REALLY strange error :-) I have a for-loop and after 8 runs I get strange results...... I mean: A really strange result.... I'm calculating...
12
by: StephQ | last post by:
I have a class Bounds with two constructors: class Bounds { private: list<SegmentupperLinearSpline; // Upper bound. list<SegmentlowerLinearSpline; // Lower bound. ....
8
by: Dox33 | last post by:
I ran into a very strange behaviour of raw_input(). I hope somebody can tell me how to fix this. (Or is this a problem in the python source?) I will explain the problem by using 3 examples....
5
by: ioni | last post by:
Good day, fellows! I have a strange problem – at my site there is a flash strip, that loads data dynamically. It works fine (grabs data from the remote server and presents it), however in IE7...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.