Closed fredlorenz closed 1 month ago
This is an issue related to how the library decodes values received from the driver. I am planning to get their type from the db itself and depreciate the column config. But there are some workarounds to be done for that. At the moment it will query all values in varchar format and convert it to string type. So you would get a string and you should be able to manually convert it to date format in your case. Therefore please avoid using column config when it is not necessary. Even if it's necessary, please avoid providing the type. If not providing the column config and you are still having issues with the library for this case, please let me know.
Unfortunately, I must use the columnConfig for:
query = "SELECT F30, F31 FROM PRICE_TAB WHERE F01 = '$upc'"; print('QUERY: $query'); results = mssqlConnection.execute( query, columnConfig: { 'F30': ColumnType(type: SQL_C_DOUBLE, size: 1), 'F31': ColumnType(type: SQL_C_DOUBLE, size: 1), }, );
Otherwise, I get a memory allocation error. If I remove the type (like ColumnType(size: 255)) and change the size to 255, I still get a memory allocation error. If I keep the columnConfig and set type to SQL_C_CHAR and size to 255 (like ColumnType(type: SQL_C_CHAR, size: 255)), I still get garbled characters. Getting a string "24.69" or "1.99" would be perfect, I could go from there. But, whatever I do, I either get garbled strings or memory allocation errors.
That does sound like a different issue. I tried just now with default column type and recieved a string value of column with type "float" on sql server. To find the issue with your setup can you tell what database and the data type of the column you are using?
I am using Microsoft SQL Server 2016. The table seems to have data types setup for each field:
For the two fields I am interested in in the code snippet above, F30 has type money and F31 has type float.
Both money and float are working perfectly with default column config. I have verified both data types with SQL server.
Closing due to inactivity
It looks like one of the issues has definitely been fixed. Thank you. But I am still having this issue:
When I execute the following code (it only executes when I add the columnConfig, and gives a memory allocation error otherwise)
query = "SELECT F30, F31 FROM PRICE_TAB WHERE F01 = '$upc'"; print('QUERY: $query'); results = mssqlConnection.execute( query, columnConfig: { 'F30': ColumnType(type: SQL_C_DOUBLE, size: 1), 'F31': ColumnType(type: SQL_C_DOUBLE, size: 1), }, ); // Display all key value pairs for results[0] results[0].forEach((key, value) { print('Key: $key, Value: $value'); });
I get
flutter: Key: F30, Value: ꏗ㵰휊㿿�௳䉮蠀 flutter: Key: F31, Value: 㿰섨௩塓蠀
F30 and F31 are supposed to be monetary values (doubles) and both look fine in the SQL database. I added an image of the table values. They are doubles.
I tried different datatypes and sizes, and nothing seems to work. I really don't like adding columnConfigs. None of the tables contains large amounts of data:
I haven't tried it, but given that I am having the issue with the above, I seriously doubt the SELECT * FROM ... issue is working.
Can you provide a better explanation of how to use columnConfig and provide some more concrete examples?