Problem with Delphi XE2 using parameters in SQL query [Edit]

Hello,
I have problem with using SQL with parameters.
This part of code works fine on Delphi 2007, but have Debugger Exception Notification in Delphi XE2

with ADOTmp do                 *//works fine on Delphi2007 and Delphi XE2, date value is inserted*
begin
  SQL.Clear;
  *SQL.Add('UPDATE Table SET Date = ''2012-04-03 13:13:13'' ');* 
  ExecSQL;
end;

with ADOTmp do                 *//works fine on Delphi2007*
begin
  SQL.Clear;
  *SQL.Add('UPDATE Table SET Date = :D1 ');* 
  Parameters.ParamByName('D1').DataType := ftDateTime;
  Parameters.ParamByName('D1').Value := '2012-04-03 10:11:12';
  ExecSQL;
end;

In Delphi XE2 I get an error:
*Debugger Exception Notification*
*Project Test.exe raised exception class EOleException with message 'Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another'.*

The error pop up when the code is on a bold area. If I press Continue, the value is inserted, but the time value in database is 00:00:00. It should be 10:11:12, the date value is correct.

I am using Windows7, DElphi XE2, TADOQuery, TADOconnection and connection string is 
Conn1.ConnectionString := 'Provider=MSDASQL.1;Persist Security Info=False;Data Source=' + ODBC + ';Mode=ReadWrite;';
where ODBC is name of ODBC source. ODBC driver is MySQL ODBC 3.51 Driver and database is MySQL 5.5.

The same error accur with every other parameter datatype (integer, string), but data is correctly inserted. Problem is also with SELECT not only UPDATE sentance.

Thanks for any help.
Matija

Edited by: Matija Murn on Apr 4, 2012 4:22 PM
0
Matija
4/8/2012 3:33:08 PM
embarcadero.delphi.ado 597 articles. 1 followers. Follow

4 Replies
3725 Views

Similar Articles

[PageSpeed] 35

"Matija Murn" wrote in message news:458972@forums.embarcadero.com...
>
> with ADOTmp do                 *//works fine on Delphi2007*
> begin
>  SQL.Clear;
>  *SQL.Add('UPDATE Table SET Date = :D1 ');*
>  Parameters.ParamByName('D1').DataType := ftDateTime;
>  Parameters.ParamByName('D1').Value := '2012-04-03 10:11:12';
>  ExecSQL;
> end;


Try assigning it as an actual date type:

  Parameters.ParamByName('D1').Value := EncodeDate(2012,04,03) + 
EncodeTime(10,11,12,00);


-- 
Wayne Niddery (TeamB)
"'Thank you, Occupy Wall Street. With your vivid example of anticapitalist 
squalor, I've been able to convince all three of my children to become 
investment bankers"  - P. J. O’Rourke
0
Wayne
4/8/2012 11:02:30 PM
Hello,

I try your way
Parameters.ParamByName('D1').Value := EncodeDate(2012,04,03) + EncodeTime(10,11,12,00);
but I get the same error.

I don't thing that the error is here, while when I use F7 command to excecute line by line I get the error in botton line

*SQL.Add('UPDATE Table SET Date = :D1 ');*

where the parameters is just assigned but not defined.

Regards,
Matija
0
Matija
4/11/2012 12:43:53 PM
Hello Matija,

try using a different variable name in your database instead of "Date". I 
am not sure what database you use but in some cases one can not use a prescribed 
variable name (such as date).

Bruce

> Hello,
> I have problem with using SQL with parameters.
> This part of code works fine on Delphi 2007, but have Debugger
> Exception Notification in Delphi XE2
> with ADOTmp do                 *//works fine on Delphi2007 and Delphi
> XE2, date value is inserted*
> begin
> SQL.Clear;
> *SQL.Add('UPDATE Table SET Date = ''2012-04-03 13:13:13'' ');*
> ExecSQL;
> end;
> with ADOTmp do                 *//works fine on Delphi2007*
> begin
> SQL.Clear;
> *SQL.Add('UPDATE Table SET Date = :D1 ');*
> Parameters.ParamByName('D1').DataType := ftDateTime;
> Parameters.ParamByName('D1').Value := '2012-04-03 10:11:12';
> ExecSQL;
> end;
> In Delphi XE2 I get an error:
> *Debugger Exception Notification*
> *Project Test.exe raised exception class EOleException with message
> 'Arguments are of the wrong type, are out of acceptable range, or are
> in conflict with one another'.*
> The error pop up when the code is on a bold area. If I press Continue,
> the value is inserted, but the time value in database is 00:00:00. It
> should be 10:11:12, the date value is correct.
> 
> I am using Windows7, DElphi XE2, TADOQuery, TADOconnection and
> connection string is
> 
> Conn1.ConnectionString := 'Provider=MSDASQL.1;Persist Security
> Info=False;Data Source=' + ODBC + ';Mode=ReadWrite;';
> 
> where ODBC is name of ODBC source. ODBC driver is MySQL ODBC 3.51
> Driver and database is MySQL 5.5.
> 
> The same error accur with every other parameter datatype (integer,
> string), but data is correctly inserted. Problem is also with SELECT
> not only UPDATE sentance.
> 
> Thanks for any help.
> Matija
> Edited by: Matija Murn on Apr 4, 2012 4:22 PM
>
0
Bruce
4/18/2012 3:06:26 AM
Hello Bruce

I use MySQL database and I use different name in my program. Here was unlucky example, where I try to show, that the field in database is a DateTime format.
With different name I still get this exception in debug mode.

Matija

> {quote:title=Bruce Eglington wrote:}{quote}
> Hello Matija,
> 
> try using a different variable name in your database instead of "Date". I 
> am not sure what database you use but in some cases one can not use a prescribed 
> variable name (such as date).
> 
> Bruce
> 
> > Hello,
> > I have problem with using SQL with parameters.
> > This part of code works fine on Delphi 2007, but have Debugger
> > Exception Notification in Delphi XE2
> > with ADOTmp do                 *//works fine on Delphi2007 and Delphi
> > XE2, date value is inserted*
> > begin
> > SQL.Clear;
> > *SQL.Add('UPDATE Table SET Date = ''2012-04-03 13:13:13'' ');*
> > ExecSQL;
> > end;
> > with ADOTmp do                 *//works fine on Delphi2007*
> > begin
> > SQL.Clear;
> > *SQL.Add('UPDATE Table SET Date = :D1 ');*
> > Parameters.ParamByName('D1').DataType := ftDateTime;
> > Parameters.ParamByName('D1').Value := '2012-04-03 10:11:12';
> > ExecSQL;
> > end;
> > In Delphi XE2 I get an error:
> > *Debugger Exception Notification*
> > *Project Test.exe raised exception class EOleException with message
> > 'Arguments are of the wrong type, are out of acceptable range, or are
> > in conflict with one another'.*
> > The error pop up when the code is on a bold area. If I press Continue,
> > the value is inserted, but the time value in database is 00:00:00. It
> > should be 10:11:12, the date value is correct.
> > 
> > I am using Windows7, DElphi XE2, TADOQuery, TADOconnection and
> > connection string is
> > 
> > Conn1.ConnectionString := 'Provider=MSDASQL.1;Persist Security
> > Info=False;Data Source=' + ODBC + ';Mode=ReadWrite;';
> > 
> > where ODBC is name of ODBC source. ODBC driver is MySQL ODBC 3.51
> > Driver and database is MySQL 5.5.
> > 
> > The same error accur with every other parameter datatype (integer,
> > string), but data is correctly inserted. Problem is also with SELECT
> > not only UPDATE sentance.
> > 
> > Thanks for any help.
> > Matija
> > Edited by: Matija Murn on Apr 4, 2012 4:22 PM
> >
0
Matija
4/25/2012 8:53:58 PM
Reply:

Similar Artilces:

Problem with printing, using Delphi XE2 [Edit]
I have problem with printing images using Delphi XE2. I have code Delphi 7, and this code work very well. {code} procedure Print; var ImgName: string; rect: TRect; jpg: TJPEGImage; begin OpenPictureDialog1.Execute; ImgName := OpenPictureDialog1.FileName; rect.TopLeft:=Point(0,0); rect.BottomRight:=Point(Printer.PageWidth,Printer.PageHeight); jpg := TJPEGImage.Create; jpg.LoadFromFile(ImgName); Printer.BeginDoc; Printer.Canvas.StretchDraw(rect,jpg); Printer.EndDoc; end; {code} But this code Delphi XE2 is not work, printer print clear sheets. (HP ...

How to create a Delphi 7 ADO "LIVE" (auto update) query to SQL Server [Edit]
How to create a Delphi 7 ADO "LIVE" query (one SQL Server table only) that once a table field is edited - the underlying query results are updated. Kind of like the "LIVE" query concept from the BDE etc. Below is the ADO query that I am using and it generally *seems* to work well where once a field is edited (via TADOQuery.Edit, .Post etc), the query result are also changed. I think it is true that after an edit the change is always visible in the same program using the same query object. {code}procedure ExecuteQryTable( Connection: TADOConnection; Qry: TADOQuer...

Problem using InstallAware 7 CodeGear Special Edition with Delphi 2010 [Edit]
Hi Everyone, I am trying to create an installation disk for my delphi 2010 application using the installAware that kind of comes with Delphi 2010. When I try to built it, it keeps giving me the error message:- No files matching pattern "C:\Windows\system32\\*120.bpl" and when I look into my windows\system32 folder, there the files with extension *.bpl end with *140.bpl and not *120.bpl like it was expected. Can anyone tell me if I am doing something wrong or how I can get around this. Thanks in advance. Edited by: Tat Hon Chu on Dec 3, 2009 12:55 AM > {quo...

Delphi 2006 to Delphi XE Crystal BPL problem [Edit]
I am in the process of migrating our application from Delphi 2006 to Delphi XE and, for ease of use, I have both 2006 and XE installed on my development computer. I access Crystal Reports XI RDC in our application and so I rebuilt the BPL in XE in order to add the new package to XE. However, when I try to add the package to XE I get the error message: “Registration procedure, Craxddrt_tbl.Register in the package c:\Documents and Settings\All Uers\Documents\RADS Studio\8.0\BPL\Crystal.bpl raised exception class EFilerError: Component TDatabase can’t be registered by package crystal.bpl be...

Problem with query delphi 2010 [Edit]
Problem with query delphi 2010 Staff when I perform the query below I describe the following error occurs: Exception class EAccessViolation with message 'Access violation at address in module 03E64A60' dbxora.dll '. Write of address 004B0041 '. Process PdvMultiEmpresa.exe (5704). The query that esecuto is as follows: SQL.Add ('SELECT *'); SQL.Add ('FROM TABLE (pac_pdv_totalcard.CONSULTA_CONTA_CARTAO (: p_cod_empresa,: p_cpf,: p_nro_cartao,: p_nro_conta ))'); ParamByName ('p_cod_empresa'). AsFmtBcd: = IntegerToBcd...

converting delphi 2007 code to delphi XE2 -- emptyparam problem
Hi, I am trying to convert my applicantion code from delphi 2007 to delphi XE2 and i got stuck in this error "[DCC Error] ADODB_TLB.pas(4888): E2033 Types of actual and formal var parameters must be identical". This happens when we use emptyparam as an argument in a function that wants an olevariant. Example: function TAcadDatabase.CopyObjects(Objects: OleVariant): OleVariant; begin Result := DefaultInterface.CopyObjects(Objects, EmptyParam, EmptyParam); //this is where we get the ERROR end; The coyobjects function as this signature: " function CopyObjects(Object...

TDatamodule problem on Delphi XE2 [Edit]
I reported a problem to QC (#100324) that I think is related with this issue. I've a project that I'm trying to compile with Delphi XE2 and when I close the application or close a form that links to the datamodule where my main connection to Interbase database is located, I'm geting this error message: First chance exception at $0061BCEA. Exception class $C0000005 with message 'access violation at 0x0061bcea: read of address 0x80808088'. Process Fac2011.exe (5608) For example, I have a form with a TIBTransaction and a TIBQuery that are linked to a TIBDatabase that b...

Code regardin post: Spread 8 COM
This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --JivePart=_5f856.zeB8CwDOH5aMJzMl Content-Type: text/plain; charset="Utf-8" Code samples Spread Custom Cell Sample.zip = Delphi code Spread_ActiveX_Samples.zip = GrapeCity sample (VB, VC) -- Regards, Ronald Hoek Application Developer ComponentAgro B.V. Oud-Beijerland - The Netherlands http://www.componentagro.nl KvK: H24264020 --JivePart=_5f856.zeB8CwDOH5aMJzMl Content-Type: application/zip; name="Spread_Act...

Debugging in Delphi XE2 using another Delphi BDS process as host
Hi I've been using delphi a long time And I always had the possibility of debbuging Packages using another Delphi process as host. This is very useful to test the design-time side of packages. Now with XE 2 I can whether running with options - Debugger - Host Application or Attach to process Any ideas? Thanks Plp Pedro wrote: > Now with XE 2 I can whether running with options - Debugger - Host > Application or Attach to process What exactly are you having trouble with? Error messages, unexpected behavior, etc. -- Remy Lebeau (TeamB) Hi Remy ...

Access to legacy (Delphi 4) Midas server from Delphi XE2 [Edit]
Hello, My company biggest product is developped with Delphi 4 and uses several Midas servers. It's a really big application (still in evolution, since 1997) , that has been started with Delphi 3. A partial or complete rewrite of this application is planned in a mid term future, and I must study if we can envisage a soft migration of some parts of the software on Delphi XE2 (or XE4), or if a complete rewrite even of the servers parts is required. If a complete rewrite must be done, my boss doesn't exclude to study the possibility of using another development environment to rewri...

Delphi 7 to Delphi XE2
Hi, Still using that old workhorse, Delphi7, but am going to the conference in London hosted by Embarcadero on Delphi XE2. Although I would like to "move with the times" and am keen to get the UNICODE and 64-bit support offered by the latest IDEs, I confess to being more than a little scared about all the UNICODE/String/AnsiString and 32/64 bit issues I'm probably going to fall over. Anyone recently upgraded from Delphi7 to one of the latest Delphi IDEs? Thanks, Alain On 03/02/2012 08:55, Alain Dekker wrote: > Still using that old workhorse, Delphi7, but...

Problem using Delphi 6 with Windows 7 [Edit]
I have had all kind of problems with Delphi 6 and Windows 7. For example, when I try to open a TStringList file over a network drive I get the following error message (MyList.LoadFromFile(s:\info\tables\table.doc);): "--------------------------- Debugger Exception Notification -------------------------------------------------------------------------------- Project Tools_CREG.exe raised exception class EFOpenError with message 'Cannot open file ...\table.doc'. Process stopped. Use Step or Run to continue. --------------------------------------------------------------...

Problem with Delphi using Titan 2000 for SQL Anywhere
I have a big problem using Titan 2000 components for Delphi 5.0 (www.reggatta.com). I know this group is not the correct place for this posting, but there is no way to get support information from Reggatta. May be is here is somebody who knows it. My Problem: We are using a SQL Anywhere 5.5.04 Database (CP 850, multilingual). For string conversion into local languages in Titan 2000 are two RegistryKeys responsible: HKLM\Software\Titan\SQLAnywhere\Configuration\Intl\IgnoreAnsiOEM = "0" and HKLM\Software\Titan\SQLAnywhere\Configuration\Intl\IgnoreOEMAnsi= "0"...

SEPA components for Delphi with Source Code (Delphi 5
Hi all, in the european union change next year the Bankingformat to the SEPA Format. All peoples and companies must change the bankingssoftware and the costumer data form acountnummers in the new IBAN and BIC numbers. See: http://www.arma-it.de/shop/artikelueber.php?wgruppeid=211&wgruppe_offen=211 Functions: - generate SEPA XML'S - Calc IBAN - BIC Database (DE,AT and CH) Questions: vertrieb@arma-it.de PS: Bankinssoftware for Develpoers (Germany only) http://www.arma-it.de/shop/artikelueber.php?wgruppeid=212&wgruppe_offen=212 El 26/10/13 21:38, A...

Web resources about - Problem with Delphi XE2 using parameters in SQL query [Edit] - embarcadero.delphi.ado

Parameter - Wikipedia, the free encyclopedia
A parameter (from the Ancient Greek παρά , "para", meaning "beside, subsidiary" and μέτρον , "metron", meaning "measure"), in its common meaning, ...

fb_source Parameter - Facebook-Entwickler
This document lists the complete list of values for the fb_source parameter that is returned with th...

Google / Firefox Parameter - Flickr - Photo Sharing!
HS what? www.seroundtable.com/archives/017105.html

Cat 8: TIA performance standards committee chairman previews parameters of forthcoming twisted-pair cable ...
Category 8, the next-generation twisted-pair cabling specification, is still in development, but the outlook looks quite positive that it will ...

Philippine president asks for 'parameters' of Mayon Volcano tours
Philippine president asks for 'parameters' of Mayon Volcano tours People's Daily Online ... 26, 27, 28, 29, 30, 31. Jan, Feb, Mar, Apr, May, ...

Alternatives to boolean parameters
... ) { PrintLine ( item . Name ); if ( printDetails ) { PrintLine ( item . Description ); } } } Aha! Now can see that the boolean parameter ...

Exporting Error (Error in Parameter...: Apple Support Communities
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability ...

Apple tech monitors device aging, adjusts operating parameters to ensure optimal performance
... describing a method of monitoring the aging of a device's electronics, comparing the data with a global average and modifying operating parameters ...

Is it poor programming practice to pass parameters as objects?
... a free, community-powered network of 100+ Q&A sites . Risser asked: So, we've got a guy who likes to write methods that take Objects as parameters, ...

Parameter Short Film Competition sponsored by Grolsch
Grolsch presents Parameter The A.V. Club Short Film Competition Please Enter Your Date of Birth Ineligible entry Enter For people over the age ...

Resources last updated: 12/20/2015 10:16:47 PM