Re: STRANGE PROBLEM
- From: "Chan Ming Man" <chanmmn@xxxxxxxxxxx>
- Date: Sat, 3 Feb 2007 15:24:00 +0800
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 steppressing 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
.
- References:
- STRANGE PROBLEM
- From: kmitzu
- STRANGE PROBLEM
- Prev by Date: Re: Install base of .NET 1.1
- Next by Date: Re: alternate controls for ToolStrip and MenuStrip?
- Previous by thread: STRANGE PROBLEM
- Next by thread: Re: Problem creating folder in C# Asp.Net
- Index(es):
Relevant Pages
|