🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #632

BCB6 and Microsoft Access

#632
From: poojo hackma
Date: Thu, 03 Nov 2005 15:57
67 lines
3510 bytes
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: <436a3378$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,6e69ea7a73810c24,start
X-Google-Attributes: gid10698b,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "poojo hackma" <poojo.com/mail>
Newsgroups: borland.public.cppbuilder.database.ado
Subject: BCB6 and Microsoft Access
Date: Thu, 3 Nov 2005 09:57:51 -0600
Lines: 70
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
X-Antivirus: avast! (VPS 0544-6, 11/03/2005), Outbound message
X-Antivirus-Status: Clean
NNTP-Posting-Host: 12.45.133.147
Message-ID: <436a3378$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1131033464 12.45.133.147 (3 Nov 2005 07:57:44 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail