![]() |
Delphi TmysqlQuery
Hi,
I am using Tmysqlquery and TmySqlUpdateSQL to update(insert/delete/modify) the database concring user input, but i get the error "you have an error in your sql syntax near 'OC2000000A000000201' EmySqldatabase error" i have checked several times the query and database connection, everything is fine but i dont have any idea why i get this error do you have any idea? |
AW: Delphi TmysqlQuery
Without the complete Query it's very hard to impossible to help you.
|
AW: Delphi TmysqlQuery
Zitat:
LOG it for debugging purposes. Or maybe post the query here... |
AW: Delphi TmysqlQuery
as i have used tmysqlquery instead TQuery ,therefore I have one idea, it can happend becasue of tmysqlquery component?
here is the code for insert (it is from dfm)
Code:
modify
insert into TableAdd
(Name, Address, Phone, Emial, Date) values (:Name, :Address, :Phone, :Emial, :Date)
Code:
delete
update TableAdd
set Name= :Name, Address= :Address, Phone= :Phone, Emial= :Emial, Date= :Date where ID = :OLD_ID
Code:
delete from TableAdd
where ID = :ID |
AW: Delphi TmysqlQuery
What happens when you quote the fieldnames?
Code:
At least "Date" is quite surely a reserved word because there is a corresponding data type.
insert into TableAdd
(`Name`, `Address`, `Phone`, `Emial`, `Date`) values (:Name, :Address, :Phone, :Emial, :Date) |
AW: Delphi TmysqlQuery
I have tried as you suggested even i have also tried by changing the name of the date field
Code:
but still have the same error, by the way,how can i check System.DateTime value and MySql.Data.Types.MySqlDate, maybe the datetime of the system and the mysqlDate is not matching, its just my idea,what do you think?
insert into TableAdd
(`Name`, `Address`, `Phone`, `Emial`, `Date`) values (:Name, :Address, :Phone, :Emial, :Date) |
AW: Delphi TmysqlQuery
SQL-Parameters are usually parsed automatically. Maybe your field is a timestamp instead of a Date/DateTime? It is hard to find a solution when you don' t know either the table structure nor the Delphi-code used to execute your queries.
|
AW: Delphi TmysqlQuery
the field 'Date' is a DateTime field,
|
AW: Delphi TmysqlQuery
Hi,
please try this one:
Delphi-Quellcode:
xxx.ParamByName('Date').AsString := FormatDateTim('yyyy-mm-dd', YourDateValue);
cu |
AW: Delphi TmysqlQuery
the querystring is done by using dfm with field and parameter
how can i use
Code:
xxx.ParamByName('Date').AsString := FormatDateTim('yyyy-mm-dd', YourDateValue);
|
AW: Delphi TmysqlQuery
You have to fill the parameters with values before you execute your statement. Didn' t you do this?
|
AW: Delphi TmysqlQuery
Please check while debugging Tmysqlquery.Text. This is the SQL statement passed to MySQL.
|
AW: Delphi TmysqlQuery
Hi,
i have debug the application and i have found that, the system date format is: 2013-09-04(yy-mm-dd) but the database query dateformat shows the: 04-09-2013(dd-mm-yy) how to make it similar formate? |
AW: Delphi TmysqlQuery
You can try using
![]() |
AW: Delphi TmysqlQuery
i have tried the follwoing ,but still have the same problem
Code:
QueryAdd1.ParamByName('DateNew').AsString:= FormatDateTim('yyyy-mm-dd', DateNew);
|
AW: Delphi TmysqlQuery
Why not
Delphi-Quellcode:
or
QueryAdd1.ParamByName('DateNew').Value := DateNew;
Delphi-Quellcode:
What type has the field in the DB?
QueryAdd1.ParamByName('DateNew').AsDate := DateNew;
|
AW: Delphi TmysqlQuery
in DB it is DateTime field
|
AW: Delphi TmysqlQuery
Then use .Value
|
AW: Delphi TmysqlQuery
i have used .value but its the same :(
|
AW: Delphi TmysqlQuery
Is your error still ? :
Zitat:
|
AW: Delphi TmysqlQuery
how can i convert dateformate from 05.09.2013 to 2013.09.05 17:00:00 using following query
Code:
but i want
query1.parambyname('newdate') := newdate //here is the 05.09.2013 17:00:00
Code:
query1.parambyname('newdate') := newdate /this formate i want 2013.09.05 17:00:00
|
AW: Delphi TmysqlQuery
What type is newdate of?
|
AW: Delphi TmysqlQuery
sorry, i forgot to mention it is DateTime formate
Code:
query1.parambyname('newdate').AsDateTime := newdate /this formate i want 2013.09.05 17:00:00
|
AW: Delphi TmysqlQuery
A Windows/Delphi DateTime isn't formated ( it's a Double!). The machnism behind the Komponents should convert the Value into the coresponding fomat. ( Unfortunately mysql unlike other dbms stores string values in the format YYYY-MM-DD HH:MM:SS instead of the use of an independant format).
But as written before, your problem seems be different of this! |
AW: Delphi TmysqlQuery
hi, finally i have found the problem, i DB there is one field as a Blob filed, i have read it as a string
forexample: 'lateId' is Blob field
Code:
Query1.ParamByName('lateID').(what to write here) := Query2.FieldByName('lateID').As(?)
|
AW: Delphi TmysqlQuery
Something like this
Delphi-Quellcode:
ms: TMemoryStream;
... try ms := TMemoryStream.Create; (Query2.FieldByName('lateID') as TBlobField).SaveToStream( ms); (Query1.ParamByName('lateID') as TBlobField).LoadFromStream( ms); finally ms.Free; end; |
AW: Delphi TmysqlQuery
can i also do the following
Code:
QueryA.ParamByName('lateId').AsString := QueryB.FieldByName('lateID').AsString
//Actually i need to do the work with fieldbyname and parambyname how to that for blobfield with parambyname and fieldbyname |
AW: Delphi TmysqlQuery
As far as can I see Markus uses both FieldByName and ParamByName.
|
AW: Delphi TmysqlQuery
Hi,
i have still this problem concerning Blob field, i have treid many ways, actually before (when the SQL manager 2010 installed in German language) i have worked with blob field and it was working fine and then i have reinstalled SQL Manager 2010 in English language after that it blob data types are not working, do you think -it can be becaause of the language of SQL Manager? |
AW: Delphi TmysqlQuery
Hi,
Code:
is it also possible to do the same for blob field similar to string/integer field?
//here 'name' is string field and i can write in the following way
QueryA.ParamByName('Name').AsString := QueryB.FieldByName('Name').AsString;
Code:
need your suggestion
//here NewID is Blob field
QueryA.ParamByName('NewID ').??? :=QueryB.FieldByName('NewID').???; //here how to define the datatype for Blob , i have tried with As TblobField but it does not work |
AW: Delphi TmysqlQuery
Did you try Markus' suggestion using a temporary MemoryStream? This should IMO do the trick.
|
AW: Delphi TmysqlQuery
A Blobfield is not a normal field, because the content isn't automatically fetched.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:15 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz