Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Specified cast is not valid

3 posts in DelphidotNet Last posting was on 2005-11-17 15:08:29.0Z
Rados³aw Wójtowicz Posted on 2005-11-16 15:09:31.0Z
From: "Rados³aw Wójtowicz" <francja@elegancja>
Newsgroups: Advantage.DelphidotNet
Subject: Specified cast is not valid
Date: Wed, 16 Nov 2005 16:09:31 +0100
Lines: 46
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 83.17.226.42
Message-ID: <437b4afe@solutions.advantagedatabase.com>
X-Trace: 16 Nov 2005 08:06:38 -0700, 83.17.226.42
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!83.17.226.42
Xref: solutions.advantagedatabase.com Advantage.DelphidotNet:73
Article PK: 1108508

Hello
I have problem with ths error when i update rows;

Specified cast is not valid.

[InvalidCastException: Specified cast is not valid.]
Advantage.Data.Provider.AdsCommand.SetParameters()

[AdsException: Invalid DbType specified for parameter ILO_ZAM.]
Advantage.Data.Provider.AdsCommand.SetParameters()
Advantage.Data.Provider.AdsCommand.ExecuteStatement(UInt32& hCursor,
String& strIndex)
Advantage.Data.Provider.AdsCommand.ExecuteNonQuery()


[code]
var
pr: AdsParameter;
IloZam: currency;

begin
pol:=AdsCommand.Create('INSERT INTO ZAMOD'+
' (FIR_KOD,TOW_KOD,ZAM_TYP,DATA,MAG_KOD,ILO_ZAM,ILO_WYD)'+
'
VALUES(:FIR_KOD,:TOW_KOD,:ZAM_TYP,:DATA,:MAG_KOD,:ILO_ZAM,:ILO_WYD)',Fconnection);
//......
//here rest of parameters
//....
pr:=AdsParameter.Create(':ILO_ZAM',dbtype.Decimal);
pr.Value:=IloZam;
pol.Parameters.Add(pr);

pr:=AdsParameter.Create(':ILO_WYD',dbtype.Decimal);
pr.Value:=IloWyd;
pol.Parameters.Add(pr);

[Code]


Specification: delphi 2005 SP3, Advantage 8 data provider .net , application
ASP .NET

Best regards
Radek


Jeremy Mullin Posted on 2005-11-17 15:05:31.0Z
Message-ID: <886edc152cae8c7b9653b3c9245@devzone.advantagedatabase.com>
From: Jeremy Mullin <no@email.com>
Subject: Re: Specified cast is not valid
Newsgroups: Advantage.DelphidotNet
References: <437b4afe@solutions.advantagedatabase.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=iso-8859-1; format=flowed
X-Newsreader: JetBrains Omea Reader 671.6
NNTP-Posting-Host: 198.102.102.44
Date: 17 Nov 2005 08:05:31 -0700
X-Trace: 17 Nov 2005 08:05:31 -0700, 198.102.102.44
Lines: 51
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!198.102.102.44
Xref: solutions.advantagedatabase.com Advantage.DelphidotNet:74
Article PK: 1108509

Have you tried changing:

IloZam: currency;

to

IloZam: decimal;

J.D. Mullin
Advantage R&D

> Hello
> I have problem with ths error when i update rows;
> Specified cast is not valid.
>
> [InvalidCastException: Specified cast is not valid.]
> Advantage.Data.Provider.AdsCommand.SetParameters()
> [AdsException: Invalid DbType specified for parameter ILO_ZAM.]
> Advantage.Data.Provider.AdsCommand.SetParameters()
> Advantage.Data.Provider.AdsCommand.ExecuteStatement(UInt32&
> hCursor,
> String& strIndex)
> Advantage.Data.Provider.AdsCommand.ExecuteNonQuery()
> [code]
> var
> pr: AdsParameter;
> IloZam: currency;
> begin
> pol:=AdsCommand.Create('INSERT INTO ZAMOD'+
> ' (FIR_KOD,TOW_KOD,ZAM_TYP,DATA,MAG_KOD,ILO_ZAM,ILO_WYD)'+
> '
> VALUES(:FIR_KOD,:TOW_KOD,:ZAM_TYP,:DATA,:MAG_KOD,:ILO_ZAM,:ILO_WYD)',F
> connection);
> //......
> //here rest of parameters
> //....
> pr:=AdsParameter.Create(':ILO_ZAM',dbtype.Decimal);
> pr.Value:=IloZam;
> pol.Parameters.Add(pr);
> pr:=AdsParameter.Create(':ILO_WYD',dbtype.Decimal);
> pr.Value:=IloWyd;
> pol.Parameters.Add(pr);
> [Code]
>
> Specification: delphi 2005 SP3, Advantage 8 data provider .net ,
> application ASP .NET
>
> Best regards
> Radek


Jeremy Mullin Posted on 2005-11-17 15:08:29.0Z
Message-ID: <886edc152caf8c7b965a5f0b70d@devzone.advantagedatabase.com>
From: Jeremy Mullin <no@email.com>
Subject: Re: Specified cast is not valid
Newsgroups: Advantage.DelphidotNet
References: <437b4afe@solutions.advantagedatabase.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=iso-8859-1; format=flowed
X-Newsreader: JetBrains Omea Reader 671.6
NNTP-Posting-Host: 198.102.102.44
Date: 17 Nov 2005 08:08:29 -0700
X-Trace: 17 Nov 2005 08:08:29 -0700, 198.102.102.44
Lines: 45
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!198.102.102.44
Xref: solutions.advantagedatabase.com Advantage.DelphidotNet:75
Article PK: 1108511

Or I think you could also use dbtype.Currency in your parameter creation.

J.D. Mullin
Advantage R&D

> Hello
> I have problem with ths error when i update rows;
> Specified cast is not valid.
>
> [InvalidCastException: Specified cast is not valid.]
> Advantage.Data.Provider.AdsCommand.SetParameters()
> [AdsException: Invalid DbType specified for parameter ILO_ZAM.]
> Advantage.Data.Provider.AdsCommand.SetParameters()
> Advantage.Data.Provider.AdsCommand.ExecuteStatement(UInt32&
> hCursor,
> String& strIndex)
> Advantage.Data.Provider.AdsCommand.ExecuteNonQuery()
> [code]
> var
> pr: AdsParameter;
> IloZam: currency;
> begin
> pol:=AdsCommand.Create('INSERT INTO ZAMOD'+
> ' (FIR_KOD,TOW_KOD,ZAM_TYP,DATA,MAG_KOD,ILO_ZAM,ILO_WYD)'+
> '
> VALUES(:FIR_KOD,:TOW_KOD,:ZAM_TYP,:DATA,:MAG_KOD,:ILO_ZAM,:ILO_WYD)',F
> connection);
> //......
> //here rest of parameters
> //....
> pr:=AdsParameter.Create(':ILO_ZAM',dbtype.Decimal);
> pr.Value:=IloZam;
> pol.Parameters.Add(pr);
> pr:=AdsParameter.Create(':ILO_WYD',dbtype.Decimal);
> pr.Value:=IloWyd;
> pol.Parameters.Add(pr);
> [Code]
>
> Specification: delphi 2005 SP3, Advantage 8 data provider .net ,
> application ASP .NET
>
> Best regards
> Radek