Thread View: borland.public.delphi.database.dotnet
2 messages
2 total messages
Started by Ephraim
Tue, 27 Feb 2007 12:42
sp in ado.net: Wrong Number of Params
Author: Ephraim
Date: Tue, 27 Feb 2007 12:42
Date: Tue, 27 Feb 2007 12:42
63 lines
2498 bytes
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;
Re: sp in ado.net: Wrong Number of Params
Author: Bob Swart
Date: Fri, 02 Mar 2007 06:34
Date: Fri, 02 Mar 2007 06:34
38 lines
2189 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads