-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: malformed mysql query for decimals
PostPosted: Fri Jul 15, 2005 3:40 am 
Newbie

Joined: Sun Jun 05, 2005 8:41 pm
Posts: 18
Hi....

I am having a problem with inserting decimals and dates into mysql database...excerpt from error log follows...couple of things are evident....
firstly:
the decimals are warped...there is a strange character like 'but when i check the contents of the textbox before and after the decimal conversion...the contents seem to be fine i.e. 45.45 comes out as 45.45 ..all fine there....so the extra character must be introduced by nhibernate

secondly:
the date is not in a aformat mysql will accept...i can convert the date into appropriate format like mydate.ToString("yyyy-MM-dd") but this is a "string" and i need a DateTime object..how do i convert the string ?

thanks in advance..all help will be appreciated....

regards,
sanjeev
/////////////////////////////////////////////////////////////////////////////////
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Impl.BatcherImpl [] <> - about to open: -6 open IDbCommands, 0 open DataReaders
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Impl.BatcherImpl [] <> - Building an IDbCommand object for the SqlString: SELECT LAST_INSERT_ID()
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Persister.EntityPersister [] <> - Dehydrating entity: bsm.Customer#
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'dsfdsfs' to parameter: 0
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'jhhkk' to parameter: 1
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'hj' to parameter: 2
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'khjk' to parameter: 3
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'hjk' to parameter: 4
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'hjk' to parameter: 5
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'hj' to parameter: 6
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'khj' to parameter: 7
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'kj' to parameter: 8
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'k' to parameter: 9
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'jkh' to parameter: 10
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'jk' to parameter: 11
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'jhkkjh' to parameter: 12
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding '56.67' to parameter: 13
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'hjjkj' to parameter: 14
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'hhkj' to parameter: 15
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding '67' to parameter: 16
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding '45.89' to parameter: 17
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding '45.67' to parameter: 18
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'jkhjk' to parameter: 19
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding '564564' to parameter: 20
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'hkjhjk' to parameter: 21
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding '78.23' to parameter: 22
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'hjkjhjk' to parameter: 23
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding '78.45' to parameter: 24
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'ghjgj' to parameter: 25
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'ghjgjh' to parameter: 26
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'jghgh' to parameter: 27
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'hjgjhg' to parameter: 28
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding '7/07/2005' to parameter: 29
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'dfhjk' to parameter: 30
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'jkhkjh' to parameter: 31
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'kjhjkhjk' to parameter: 32
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'jkhjk' to parameter: 33
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'hjhkjh' to parameter: 34
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'hkjhj' to parameter: 35
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'hkjhj' to parameter: 36
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'hjkhjk' to parameter: 37
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'jkhj' to parameter: 38
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'hkjhjk' to parameter: 39
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding '15/07/2005' to parameter: 40
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding 'hjgjhgjh' to parameter: 41
2005-07-15 12:28:40,926 [3044] DEBUG NHibernate.Type.NullableType [] <> - binding '1' to parameter: 42
2005-07-15 12:28:40,926 [3044] INFO NHibernate.Impl.BatcherImpl [] <> - Preparing INSERT INTO bsmcustomer (co_last_name, designation, card_id, card_status, currency_code, picture_notes, identifiers, custom_list_1, custom_list_2, custom_list_3, custom_field_1, custom_field_2, custom_field_3, billing_rate, terms, payment_is_due, discount_days, percent_discount, percent_monthly_charge, tax_code, credit_limit, tax_id_no, volume_discount_percent, sales_purchase_layout, price_level, payment_method, payment_notes, name_on_card, card_number, expiry_date, particulars, code, account, remittance_method, comment, shipping_method, printed_form, freight_tax_code, use_customer_tax_code, verified, lastmodified, lastmodifiedby, salesrep_id) VALUES (?p0, ?p1, ?p2, ?p3, ?p4, ?p5, ?p6, ?p7, ?p8, ?p9, ?p10, ?p11, ?p12, ?p13, ?p14, ?p15, ?p16, ?p17, ?p18, ?p19, ?p20, ?p21, ?p22, ?p23, ?p24, ?p25, ?p26, ?p27, ?p28, ?p29, ?p30, ?p31, ?p32, ?p33, ?p34, ?p35, ?p36, ?p37, ?p38, ?p39, ?p40, ?p41, ?p42)
2005-07-15 12:28:40,926 [3044] ERROR NHibernate.Persister.EntityPersister [] <> - #42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '56.67, 'hjjkj', 'hhkj', 67, 45.89, 45.67, 'jkhjk', 564564, 'hkjhjk', 78.23,' at line 1
Exception: MySql.Data.MySqlClient.MySqlException
Message: #42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '56.67, 'hjjkj', 'hhkj', 67, 45.89, 45.67, 'jkhjk', 564564, 'hkjhjk', 78.23,' at line 1
//////////////////////////////////////////////////////////////////////////////


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 15, 2005 5:30 am 
Newbie

Joined: Sun Jun 05, 2005 8:41 pm
Posts: 18
ok i managed to conver the string back into a datetime type like this....
but i lose the formatting ? it seems to revert back to it's old original format...please help....

code used:

DateTime expdate = System.DateTime.Parse(Textbox33.Text);
string fdate = expdate.ToString("yyyy-MM-dd");
addcs.expiry_date=DateTime.Parse(fdate);

whatamidoingwrong ????

regards,
sanjeev


Top
 Profile  
 
 Post subject: help me understand what's wrong with query...
PostPosted: Sun Jul 17, 2005 9:47 pm 
Newbie

Joined: Sun Jun 05, 2005 8:41 pm
Posts: 18
hello.....

i seem to be stuck unless i get through with this problem...
can someone shed some light on the malformed query ???

cheers
sanjeev


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 18, 2005 9:18 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
I don't understand what you are trying to do with your DateTime?

Code:
DateTime expdate = System.DateTime.Parse(Textbox33.Text);
string fdate = expdate.ToString("yyyy-MM-dd");
addcs.expiry_date=DateTime.Parse(fdate);


You can directly write:
Code:
addcs.expiry_date = System.DateTime.Parse(Textbox33.Text);


On side note, I had a problem with sending DateTime with a french version of SQL Server (because the order of Year, Month and Day is not the same); I solve it by using date.ToString("yyyyMMdd"); This form is always interpret the same way.

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.