[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

Update problem with ODBC.Net

Roopal Tonk

8/13/2002 10:35:00 PM

I get the following error when I try to update a dataset
which has "money" datatype going against Sybase ASE 12
database using Sybase ODBC driver:

------
Error:
------
ERROR [22018] [SYBASE][ODBC Sybase driver][SQL Server]
Implicit conversion from datatype 'CHAR' to 'MONEY' is not
allowed. Use the CONVERT function to run this query.


It seems from the error message that ODBC.Net Provider is
sending the 'DECIMAL' parameter as 'CHAR' to the ODBC
driver instead of what was suppiled in the OdbcParameter.


---------------
DataSet schema:
---------------
<?xml version="1.0" encoding="utf-16"?>
<xs:schema id="NewDataSet" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSc...
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="customer">
<xs:complexType>
<xs:sequence>
<xs:element name="cust_nr" type="xs:string"
minOccurs="0" />
<xs:element name="cred_ext_tot_amt"
type="xs:decimal" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

---------------
Update Command:
---------------
UPDATE customer SET cred_ext_tot_amt = ? WHERE cust_nr = ?

---------------------
OdbcParameter setting:
---------------------
Dim MyParm As OdbcParameter =
MyAdapter2.UpdateCommand.Parameters.Add
("@cred_ext_tot_amt", OdbcType.Decimal)
MyParm.SourceColumn = "cred_ext_tot_amt"
MyParm.DbType = DbType.Decimal
MyParm.Direction = ParameterDirection.Input
MyParm.OdbcType = OdbcType.Decimal
MyParm.Precision = 19
MyParm.Scale = 4
MyParm.Size = 0
MyParm.SourceVersion = DataRowVersion.Current


3 Answers

laled

8/20/2002 2:37:00 AM

0

Yes, we had so many problems with third party drivers
handling decimal datatype (causing back end data
corruptions etc...) that we resorted to using CHAR/WCHAR
to represent Decimal datatypes in parameters in most
cases.
If you change your update statement to reflect that,
everything should work.

UPDATE customer SET cred_ext_tot_amt = convert(money, ?)
WHERE cust_nr = ?

Thanks
Laled

>-----Original Message-----
>I get the following error when I try to update a dataset
>which has "money" datatype going against Sybase ASE 12
>database using Sybase ODBC driver:
>
>------
>Error:
>------
>ERROR [22018] [SYBASE][ODBC Sybase driver][SQL Server]
>Implicit conversion from datatype 'CHAR' to 'MONEY' is
not
>allowed. Use the CONVERT function to run this query.
>
>
>It seems from the error message that ODBC.Net Provider
is
>sending the 'DECIMAL' parameter as 'CHAR' to the ODBC
>driver instead of what was suppiled in the OdbcParameter.
>
>
>---------------
>DataSet schema:
>---------------
><?xml version="1.0" encoding="utf-16"?>
><xs:schema id="NewDataSet" xmlns=""
>xmlns:xs="http://www.w3.org/2001/XMLSc...
>xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
> <xs:element name="NewDataSet" msdata:IsDataSet="true">
> <xs:complexType>
> <xs:choice maxOccurs="unbounded">
> <xs:element name="customer">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="cust_nr" type="xs:string"
>minOccurs="0" />
> <xs:element name="cred_ext_tot_amt"
>type="xs:decimal" minOccurs="0" />
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:choice>
> </xs:complexType>
> </xs:element>
></xs:schema>
>
>---------------
>Update Command:
>---------------
>UPDATE customer SET cred_ext_tot_amt = ? WHERE cust_nr
= ?
>
>---------------------
>OdbcParameter setting:
>---------------------
>Dim MyParm As OdbcParameter =
>MyAdapter2.UpdateCommand.Parameters.Add
>("@cred_ext_tot_amt", OdbcType.Decimal)
>MyParm.SourceColumn = "cred_ext_tot_amt"
>MyParm.DbType = DbType.Decimal
>MyParm.Direction = ParameterDirection.Input
>MyParm.OdbcType = OdbcType.Decimal
>MyParm.Precision = 19
>MyParm.Scale = 4
>MyParm.Size = 0
>MyParm.SourceVersion = DataRowVersion.Current
>
>
>.
>

Roopal Tonk

8/26/2002 4:56:00 PM

0

Thanks for the reply.

Were you able to narrow down whether is was a Microsoft or
Driver issue?

Does anyone know if there are Service Packs available for
ODBC.Net?


>-----Original Message-----
>Yes, we had so many problems with third party drivers
>handling decimal datatype (causing back end data
>corruptions etc...) that we resorted to using CHAR/WCHAR
>to represent Decimal datatypes in parameters in most
>cases.
>If you change your update statement to reflect that,
>everything should work.
>
>UPDATE customer SET cred_ext_tot_amt = convert(money, ?)
>WHERE cust_nr = ?
>
>Thanks
>Laled
>
>>-----Original Message-----
>>I get the following error when I try to update a dataset
>>which has "money" datatype going against Sybase ASE 12
>>database using Sybase ODBC driver:
>>
>>------
>>Error:
>>------
>>ERROR [22018] [SYBASE][ODBC Sybase driver][SQL Server]
>>Implicit conversion from datatype 'CHAR' to 'MONEY' is
>not
>>allowed. Use the CONVERT function to run this query.
>>
>>
>>It seems from the error message that ODBC.Net Provider
>is
>>sending the 'DECIMAL' parameter as 'CHAR' to the ODBC
>>driver instead of what was suppiled in the OdbcParameter.
>>
>>
>>---------------
>>DataSet schema:
>>---------------
>><?xml version="1.0" encoding="utf-16"?>
>><xs:schema id="NewDataSet" xmlns=""
>>xmlns:xs="http://www.w3.org/2001/XMLSc...
>>xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
>> <xs:element name="NewDataSet" msdata:IsDataSet="true">
>> <xs:complexType>
>> <xs:choice maxOccurs="unbounded">
>> <xs:element name="customer">
>> <xs:complexType>
>> <xs:sequence>
>> <xs:element name="cust_nr" type="xs:string"
>>minOccurs="0" />
>> <xs:element name="cred_ext_tot_amt"
>>type="xs:decimal" minOccurs="0" />
>> </xs:sequence>
>> </xs:complexType>
>> </xs:element>
>> </xs:choice>
>> </xs:complexType>
>> </xs:element>
>></xs:schema>
>>
>>---------------
>>Update Command:
>>---------------
>>UPDATE customer SET cred_ext_tot_amt = ? WHERE cust_nr
>= ?
>>
>>---------------------
>>OdbcParameter setting:
>>---------------------
>>Dim MyParm As OdbcParameter =
>>MyAdapter2.UpdateCommand.Parameters.Add
>>("@cred_ext_tot_amt", OdbcType.Decimal)
>>MyParm.SourceColumn = "cred_ext_tot_amt"
>>MyParm.DbType = DbType.Decimal
>>MyParm.Direction = ParameterDirection.Input
>>MyParm.OdbcType = OdbcType.Decimal
>>MyParm.Precision = 19
>>MyParm.Scale = 4
>>MyParm.Size = 0
>>MyParm.SourceVersion = DataRowVersion.Current
>>
>>
>>.
>>
>.
>

Roopal Tonk

8/27/2002 4:36:00 PM

0

I was successfully able to use your workaround solution.
Thanks.

Is there a reason that you are using the ODBC driver & not
the OLEDB driver?



>-----Original Message-----
>Yes, we had so many problems with third party drivers
>handling decimal datatype (causing back end data
>corruptions etc...) that we resorted to using CHAR/WCHAR
>to represent Decimal datatypes in parameters in most
>cases.
>If you change your update statement to reflect that,
>everything should work.
>
>UPDATE customer SET cred_ext_tot_amt = convert(money, ?)
>WHERE cust_nr = ?
>
>Thanks
>Laled
>
>>-----Original Message-----
>>I get the following error when I try to update a dataset
>>which has "money" datatype going against Sybase ASE 12
>>database using Sybase ODBC driver:
>>
>>------
>>Error:
>>------
>>ERROR [22018] [SYBASE][ODBC Sybase driver][SQL Server]
>>Implicit conversion from datatype 'CHAR' to 'MONEY' is
>not
>>allowed. Use the CONVERT function to run this query.
>>
>>
>>It seems from the error message that ODBC.Net Provider
>is
>>sending the 'DECIMAL' parameter as 'CHAR' to the ODBC
>>driver instead of what was suppiled in the OdbcParameter.
>>
>>
>>---------------
>>DataSet schema:
>>---------------
>><?xml version="1.0" encoding="utf-16"?>
>><xs:schema id="NewDataSet" xmlns=""
>>xmlns:xs="http://www.w3.org/2001/XMLSc...
>>xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
>> <xs:element name="NewDataSet" msdata:IsDataSet="true">
>> <xs:complexType>
>> <xs:choice maxOccurs="unbounded">
>> <xs:element name="customer">
>> <xs:complexType>
>> <xs:sequence>
>> <xs:element name="cust_nr" type="xs:string"
>>minOccurs="0" />
>> <xs:element name="cred_ext_tot_amt"
>>type="xs:decimal" minOccurs="0" />
>> </xs:sequence>
>> </xs:complexType>
>> </xs:element>
>> </xs:choice>
>> </xs:complexType>
>> </xs:element>
>></xs:schema>
>>
>>---------------
>>Update Command:
>>---------------
>>UPDATE customer SET cred_ext_tot_amt = ? WHERE cust_nr
>= ?
>>
>>---------------------
>>OdbcParameter setting:
>>---------------------
>>Dim MyParm As OdbcParameter =
>>MyAdapter2.UpdateCommand.Parameters.Add
>>("@cred_ext_tot_amt", OdbcType.Decimal)
>>MyParm.SourceColumn = "cred_ext_tot_amt"
>>MyParm.DbType = DbType.Decimal
>>MyParm.Direction = ParameterDirection.Input
>>MyParm.OdbcType = OdbcType.Decimal
>>MyParm.Precision = 19
>>MyParm.Scale = 4
>>MyParm.Size = 0
>>MyParm.SourceVersion = DataRowVersion.Current
>>
>>
>>.
>>
>.
>