Article View: borland.public.cppbuilder.database.ado
Article #633Re: BCB6 and Microsoft Access
From: Viatcheslav V. Vassiliev
Date: Thu, 03 Nov 2005 20:13
Date: Thu, 03 Nov 2005 20:13
88 lines
4263 bytes
4263 bytes
I think Len and Bit are keywords in Jet SQL. Try:
INSERT INTO [SPNs] ([SPN], [Len], [Bit]) VALUES (%d, %d, %d)
The same for UPDATE. With column names you use I would brace ([...]) every
column and table name, Min and Max are likely keywords too.
//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"poojo hackma" <poojo.com/mail> �������/�������� � �������� ���������:
news:436a3378$1@newsgroups.borland.com...
> Could someone *please* spell out how to UPDATE or INSERT records into a
> Microsoft Access database? My SQL is correct as far as SQL standards go,
> but I keep getting exceptions saying I have an error in my UPDATE or my
> INSERT commands.
>
> My MS Access database has 2 types of fields: Numbers and Text. The Field
> Size for the Numbers are either Long Integer or Double, and the Field Size
> for the Text type is 50.
>
> Here is the MS Access Table:
> ______SPNs : Table________
> Name_ Type__ Size________
> SPN Number Long Integer
> Desc Text 50
> Len Number Long Integer
> Res Number Double
> Ofs Number Double
> Min Number Double
> Max Number Double
> Unit Text 10
>
> Here are my values defined in BCB6:
> AnsiString strSql;
> int spn, len, bit;
> char desc[50], unit[7];
> double res, ofs, min, max;
>
> This INSERT statement is successful, so you know I am connecting:
> strSql.printf("INSERT INTO SPNs (SPN) VALUES (%d)", spn);
> ADOCommand1->CommandText = strSql;
> ADOCommand1->Execute();
>
> This statement produces "error in INSERT command" exception:
> strSql.printf("INSERT INTO SPNs (SPN, Len, Bit) VALUES (%d, %d, %d)", spn,
> len, bit);
>
> ADOCommand1->CommandText = strSql;
> ADOCommand1->Execute();
>
> After the successful INSERT statement above, this UPDATE statement fails
> with "error in UPDATE command:"
> strSql.printf("UPDATE SPNs SET Len = %d, Bit = %d WHERE SPN = %d", len,
> bit, spn);
> ADOCommand1->CommandText = strSql;
> ADOCommand1->Execute();
>
> Also, this UPDATE fails with "error in UPDATE command:"
> strSql.printf("UPDATE SPNs SET Res = %.5lf, Ofs = %.5lf, Min = %.5lf, Max
> = %.5lf WHERE SPN = %d", res, ofs, min, max, spn);
> ADOCommand1->CommandText = strSql;
> ADOCommand1->Execute();
>
> And this UPDATE fails with "error in UPDATE command:"
> strSql.printf("UPDATE SPNs SET Desc = '%s', Unit = '%s' WHERE SPN = %d",
> desc, unit, spn);
> ADOCommand1->CommandText = strSql;
> ADOCommand1->Execute();
>
> Jesus! What's with this? Why is it so hard to input a record into an
> Access database with Borland? I can view the strSql data after the
> printf() routines, and they all look great! I've tried entering only the
> Integer fields, only the Text fields, and only the Double fields, but they
> each fail.
>
> Does ANYBODY have a clue what is going on or how to resolve this? I've
> also tried using Parameters and RecordSets, but I still get the same
> errors when it tries to insert the records.
>
>
>
Technical Details
Message-ID:
<436a6f56$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeed.hal-mli.net!feeder1.hal-mli.net!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<436a3378$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,6e69ea7a73810c24 X-Google-Attributes: gid10698b,public X-Google-Language: ENGLISH,ASCII From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com> Newsgroups: borland.public.cppbuilder.database.ado References: <436a3378$1@newsgroups.borland.com> Subject: Re: BCB6 and Microsoft Access Date: Thu, 3 Nov 2005 23:13:25 +0300 Lines: 90 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2670 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 X-RFC2646: Format=Flowed; Response NNTP-Posting-Host: 85.93.138.132 Message-ID: <436a6f56$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1131048790 85.93.138.132 (3 Nov 2005 12:13:10 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeed.hal-mli.net!feeder1.hal-mli.net!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail