Article View: borland.public.csharpbuilder.language.csharp
Article #132Database troubles with insert
From: Mark Smits
Date: Wed, 02 May 2007 15:03
Date: Wed, 02 May 2007 15:03
35 lines
2701 bytes
2701 bytes
Problably the wrong group but I could not find a BDS C# group and also did not find a C#builder database group. If I should post somewhere else, please tell me. I am using Altova Mapforce (www.altova.com) as a tool to map some csv files to database files. This tool generates C# source so I can build an exe or dll so I can implement that into my Delphi project. I map several CSV fields of type decimal or integer to corresponding database fields. The generated C# source translates this into an ODBC Insert statement with parameter fields. When a field in the original CSV file is empty, the value DBNull.Value is assigned to the corresponding parameter. So far everything looks ok, but when the SQL is executed I get an SQL error on invalid types: ERROR: INSERT INTO `eoedibp` (`EOEONUMM`,`EOEOSTAT`,`EOOGNUMM`,`EOEOREFE`, `EOEOGEWI`,`EOEOCOLL`,`EOEOPALL`,`EOEONAAM21`,`EOEOSTRA21`,`EOEOHSNR21`,`EOEOADRS21`, `EOQPCODE21`,`EOEOPLAA21`,`EOEODATA`,`EOEOTDVA`,`EOEOTDTA`,`EOEOBEDR33`,`EOQVCODE33`, `EOEOOPME`,`EOEOOMS1`,`EOEBNUMM`) VALUES ( '6', '10', '411607', '123458', '', '12', '', 'F.', 'P 220', '', '', 'AE', 'S', '2006-12-01', '08:00:00', '17:00:00', '', 'EUR', '', 'Allerlei Dingen', '20' ) ERROR [07006] [MySQL][ODBC 3.51 Driver][mysqld-5.0.24-community-nt]Restricted data type attribute violation(SQL_C_NUMERIC) For example the fifth field (EOEOGEWI) is decimal, but as value '' is being passed instead of NULL. So now for my question. Where do I lay the blame. Is it the db (MySQL in this case), is it the MySQL ODBC driver, is it somewhere in the used dbCommand.ExecuteReader() where things might go wrong or is it, despite assigning DBNull.Value, an issue of filling the parameters. Thanks for any pointers in the right direction.
Technical Details
Message-ID:
<4638a801@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!feeder3.cambrium.nl!feed.tweaknews.nl!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,bb7eef783de1bfc4,start X-Google-Attributes: gid1efe35,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Mark Smits" <x@x> Newsgroups: borland.public.csharpbuilder.language.csharp Subject: Database troubles with insert Date: Wed, 2 May 2007 17:03:31 +0200 Lines: 37 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.3790.2826 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.3790.2826 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 82.98.253.91 Message-ID: <4638a801@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1178118145 82.98.253.91 (2 May 2007 08:02:25 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!feeder3.cambrium.nl!feed.tweaknews.nl!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail