🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.database.dotnet
Article #34

Re: sp in ado.net: Wrong Number of Params

#34
From: Bob Swart
Date: Fri, 02 Mar 2007 06:34
38 lines
2189 bytes
Hi Ephraim,

> The form method below results in a Sybase OCBC Error "Wrong Number of
> Parameters"
> I observe (cmd.parameters) that 16 parameters are created although only 5
> are populated, the rest are null. Is this normal?

Doesn't appear normal to me. Perhaps you could clear the parameter list 
before you start to add your five?

> function TForm4.InsertMoc(const SerialId, CallOrigin, CallDestination,
> TransactionID, TimeStamp: String): Integer;
> const
>   c_cnstr='DSN=sybCK';
>   c_sp='sp_InsertNOC';
> var
>   k: Integer;
>   sqlcn: ODBCConnection;
>   cmd: ODBCCommand;
>   param: ODBCParameter;
> begin
>   try
>     sqlcn:=ODBCConnection.Create(c_cnstr);
>     cmd:=ODBCCommand.Create(c_sp, sqlcn);
>     cmd.CommandType:=CommandType.StoredProcedure;

       cmd.Parameters.Clear; // or a similar method to clear the list

>     param:=cmd.Parameters.Add('serialid', ODBCType.Char, 20);
>     param.Value:=SerialID;

Groetjes,
           Bob Swart

-- 
Bob Swart Training & Consultancy (eBob42.com)  Forever Loyal to Delphi
Blog: http://www.drbob42.com/blog - RSS: http://drbob42.com/weblog.xml
New Delphi 2006 Courseware e-books at http://www.eBob42.com/courseware
Technical Details
Message-ID: <45E7C576.50306@chello.nl>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.glorb.com!newsfeed.cw.net!cw.net!news-FFM2.ecrc.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <45e42713$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1effe6,ad2b857c8f6795b1
X-Google-Attributes: gid1effe6,public
X-Google-Language: ENGLISH,ASCII-7-bit
Message-ID: <45E7C576.50306@chello.nl>
Date: Fri, 02 Mar 2007 07:34:30 +0100
From: Bob Swart <b.swart@chello.nl>
Organization: Bob Swart Training & Consultancy (eBob42)
User-Agent: Thunderbird 1.5.0.9 (Windows/20061207)
MIME-Version: 1.0
Newsgroups: borland.public.delphi.database.dotnet
Subject: Re: sp in ado.net: Wrong Number of Params
References: <45e42713$1@newsgroups.borland.com>
In-Reply-To: <45e42713$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 213.93.59.184
X-Trace: newsgroups.borland.com 1172817261 213.93.59.184 (1 Mar 2007 22:34:21 -0800)
Lines: 38
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.glorb.com!newsfeed.cw.net!cw.net!news-FFM2.ecrc.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail