Re: STRANGE PROBLEM



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" <prea_multe@xxxxxxxxx> wrote in message news:ebdjgTfRHHA.3812@xxxxxxxxxxxxxxxxxxxxxxx


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=MarkaLink;

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

.



Relevant Pages

  • STRANGE PROBLEM
    ... im looping SqlCommand in a while loop. ... @MarkaLink NVARCHAR, ... 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 ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Parameters
    ... ALTER FUNCTION dbo.My_Function2(@order nvarchar (10), ... In the listbox simple selection mode i used the following code: ... > generated sql and drop the stored procedure, or you can make the stored ... > It looks like your performing a query against a stored procedure. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Case statement issue
    ... except with a cursor other than the default ... > I have taken the sample of paging using a stored procedure from the ... > case statement, then the error message. ... > The for loop also seems to be a problem. ...
    (microsoft.public.inetserver.asp.general)
  • Re: Case statement issue
    ... except with a cursor other than the default ... > I have taken the sample of paging using a stored procedure from the ... > case statement, then the error message. ... > The for loop also seems to be a problem. ...
    (microsoft.public.inetserver.asp.general)
  • Case statement issue
    ... Windows enterprise 2003 OS with IIS version 6 on the server. ... I have taken the sample of paging using a stored procedure from the website ... case statement, then the error message. ... The for loop also seems to be a problem. ...
    (microsoft.public.inetserver.asp.general)