🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

sp in ado.net: Wrong Number of Params

#33
From: Ephraim
Date: Tue, 27 Feb 2007 12:42
63 lines
2498 bytes
D2006 and ASA9

I wish to insert a record using a srored procedure; ADO.Net
I tested the sp via isql  (it has 5 parameters) and I can insert.

I am using ODBC to conect to ASA9.

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?
(The size propery=5). The exception occurs after
result:=cmd.ExecuteNonQuery;

What's wrong ?

YOA

Ephraim


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;

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

    param:=cmd.Parameters.Add('moc_call_origin', ODBCType.Char, 32);
    param.Value:=CallOrigin;

    param:=cmd.Parameters.Add('moc_call_destination', ODBCType.Char, 32);
    param.Value:=CallDestination;

    param:=cmd.Parameters.Add('moc_trans_id', ODBCType.Char, 12);
    param.Value:=TransactionID;

    param:=cmd.Parameters.Add('moc_timestamp', ODBCType.Char, 14);
    param.Value:=TimeStamp;

    sqlcn.Open;
    try
      result:=cmd.ExecuteNonQuery;
    finally
      sqlcn.Close;
    end;
  except
     Result:=-1000;
     raise;
  end;
end;
Technical Details
Message-ID: <45e42713$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!newsfeed.news2me.com!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 1effe6,ad2b857c8f6795b1,start
X-Google-Attributes: gid1effe6,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Ephraim" <Kosher@nospam.com>
Newsgroups: borland.public.delphi.database.dotnet
Subject: sp in ado.net: Wrong Number of Params
Date: Tue, 27 Feb 2007 12:42:10 -0000
Lines: 65
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1807
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1896
NNTP-Posting-Host: 86.141.122.57
Message-ID: <45e42713$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1172580115 86.141.122.57 (27 Feb 2007 04:41:55 -0800)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!newsfeed.news2me.com!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail