Thread View: borland.public.cppbuilder.database.ado
1 messages
1 total messages
Started by poojo hackma
Wed, 02 Nov 2005 17:49
MS Access, Parameters, and BCB6
Author: poojo hackma
Date: Wed, 02 Nov 2005 17:49
Date: Wed, 02 Nov 2005 17:49
72 lines
3837 bytes
3837 bytes
I keep getting exceptions thrown when I enter information into my database
using parameters because the INSERT statement is not correct.
I'd like to use more Parameters (TParameter), but BCB6 doesn't give an
example of how to use them. Regarding TParameter, the Help did not answer
these questions:
1. I did not see a DataType ftDouble.
Should I used ftFloat instead?
Do I enter a Size (for ftString), or leave it zero?
Do I need to specify NumericScale (digits after decimal)?
Do I need to specify Precision (total number of digits)?
2. For DataType ftLargeint:
Should I leave NumericScale = 0?
How do I determine Precision (total number of digits)?
3. For DataType ftString:
Do I leave NumericScale and Precision with their default values of 0?
Do I need to specify Size, or will it fill automatically?
My code below does not include this, but it is giving me the INSERT error:
(int spn;)
{
// For visibility, I broke up the string into multiple sections:
ADOCommand1->CommandText =
"INSERT INTO Table1 " +
" (ID,Desc,Len,Res,Ofs,Min,Max,Unit,Sus,PGN,start) " +
"VALUES " +
" (:pSP,:pDe,:pLe,:pRs,:pOs,:pMn,:pMx,:pUt,:pSp,:pPG,:pBt)";
ADOCommand1->Parameters->ParamByName("pSP")->DataType = ftLargeint;
ADOCommand1->Parameters->ParamByName("pSP")->Value = spn;
ADOCommand1->Parameters->ParamByName("pDe")->DataType = ftString;
ADOCommand1->Parameters->ParamByName("pDe")->Value = spec.desc;
ADOCommand1->Parameters->ParamByName("pLe")->DataType = ftLargeint;
ADOCommand1->Parameters->ParamByName("pLe")->Value = spec.len;
ADOCommand1->Parameters->ParamByName("pRs")->DataType = ftFloat;
ADOCommand1->Parameters->ParamByName("pRs")->Value = spec.res;
ADOCommand1->Parameters->ParamByName("pOs")->DataType = ftFloat;
ADOCommand1->Parameters->ParamByName("pOs")->Value = spec.ofs;
ADOCommand1->Parameters->ParamByName("pMn")->DataType = ftFloat;
ADOCommand1->Parameters->ParamByName("pMn")->Value = spec.min;
ADOCommand1->Parameters->ParamByName("pMx")->DataType = ftFloat;
ADOCommand1->Parameters->ParamByName("pMx")->Value = spec.max;
ADOCommand1->Parameters->ParamByName("pUt")->DataType = ftString;
ADOCommand1->Parameters->ParamByName("pUt")->Value = spec.pUnit;
ADOCommand1->Parameters->ParamByName("pSp")->DataType = ftLargeint;
ADOCommand1->Parameters->ParamByName("pSp")->Value = spec.self;
ADOCommand1->Parameters->ParamByName("pPG")->DataType = ftLargeint;
ADOCommand1->Parameters->ParamByName("pPG")->Value = spec.Group;
ADOCommand1->Parameters->ParamByName("pBt")->DataType = ftLargeint;
ADOCommand1->Parameters->ParamByName("pBt")->Value = spec.bit;
ADOCommand1->Execute();
}
// The spec struct is defined as:
struct {
int bit, len, PGN, self, xER;
double res, max, min, ofs, val;
char *pUnit, desc[50];
} spec;
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads