abduhsuryadi
New member
- Local time
- Today, 20:29
- Joined
- Aug 3, 2018
- Messages
- 1
Haloo...
I have access 2007 as Fronte End and MySQL database as Back End. Database name: myshop, table name : Sales and one of field name: Price. The type of the field is Decimal (19,4). The question is why these three code below get different result?
First code with OpenDatabase("",false,false,ConnString)
Second code with currentdb
Third code with ADODB
What is the problem in the first code? is there an option in connection string to avoid this?
I have access 2007 as Fronte End and MySQL database as Back End. Database name: myshop, table name : Sales and one of field name: Price. The type of the field is Decimal (19,4). The question is why these three code below get different result?
First code with OpenDatabase("",false,false,ConnString)
Code:
dim db as DAO.database
dim rst as DAO.recordset
set db=opendatabase("",false,false,"ODBC;Driver=MySQL ODBC 3.51 Driver;server=localhost;Database=myshop")
set rst=db.openrecordset("Sales")
debug.print rst!price
'Result : 3500.0000
debug.print rst!price + 1
'result : 35000001
Second code with currentdb
Code:
dim db as DAO.database
dim rst as DAO.recordset
set db=CurrentDb
set rst=db.openrecordset("Sales")
debug.print rst!price
'Result : 3500
debug.print rst!price + 1
'result : 3501
Third code with ADODB
Code:
dim db as New ADODB.Connection
dim rst as New ADODB.recordset
db.open "Driver=MySQL ODBC 3.51 Driver;server=localhost;Database=myshop"
rst.open "Sales",db
debug.print rst!price
'Result : 3500
debug.print rst!price + 1
'result : 3501
What is the problem in the first code? is there an option in connection string to avoid this?