ADOCommand and grave accent problem

From: David Fallas (fallasd_at_sysmexdelphic.com)
Date: 11/24/04


Date: Wed, 24 Nov 2004 15:19:31 +1300

Win2k, MDAC 2.7, Delphi 6, Update 2, SQLServer 8.0.

The following causes an ADO exception (EADOError): 'Parameter object is
improperly defined. Inconsistent or incomplete information was provided'

...
sCols:= 'testchar,testnumber,testdate';
sVals:= QuotedStr('grave accent [`]') + ',10,' +
QuotedStr(FormatDateTime('yyyymmdd hh:nn:ss', Now));
sExecute:= 'INSERT INTO testtable(' + sCols + ')VALUES(' + sVals + ')';
ADOConnection:= TADOConnection.Create(nil);
ADOCommand:= TADOCommand.Create(nil);
try
  ADOConnection.ConnectionString:= _ConnectionString;
  ADOConnection.Open;
  try
    ADOCommand.Connection:= ADOConnection;
    ADOCommand.CommandText:= sExecute;
    ADOCommand.CommandType:= cmdText;
    ADOCommand.ExecuteOptions:= [eoExecuteNoRecords];
    ADOCommand.Execute;// <----- exception raised here
...

The following does not:
...
sCols:= 'testchar,testnumber,testdate';
sVals:= QuotedStr('grave accent [`]') + ',10,' +
QuotedStr(FormatDateTime('yyyymmdd hh:nn:ss', Now));
sExecute:= 'INSERT INTO testtable(' + sCols + ')VALUES(' + sVals + ')';
ADOConnection:= TADOConnection.Create(nil);
try
  ADOConnection.ConnectionString:= _ConnectionString;
  ADOConnection.Open;
  try
    ADOConnection.Execute(sExecute, cmdText);// <----- NO exception here
...

What is it about the grave accent character in ADOCommand?

I raised this issue a couple of years ago in these news groups, but I don't
recall any responses. It's still there, and still causing headaches. Any
ideas welcome.

BTW - table definition is as follows:

CREATE TABLE testtable(
testchar VARCHAR(40),
testnumber NUMERIC,
testdate DATETIME)



Relevant Pages

  • problem using sp from vb program
    ... I'm getting this error when debugging the VB program: Parameter object is improperly defined. ... Inconsistent or incomplete information was provided. ...
    (microsoft.public.sqlserver.programming)
  • delphi newbie
    ... I started to build the query with barcode and date and that worked fine ... When I tried to add time I get the error "parameter object is improperly ... inconsistent or incomplete information was provided" ...
    (alt.comp.lang.borland-delphi)