Why MS access odbc returns numbers but no strings in C#? -


i'm using odbc connection fetch data access file (.mdb) in unity3d environment (mono.net) on windows 7 , connection, deconnection , requests happen without error.

but when read data get, receive numbers database. can integers, or float numbers. when try fetch string, return empty string.

here use in databasehandler class perform requests (extracts) :

public arraylist execute(string req) { arraylist output = new arraylist();  [...]  cmd = new odbccommand(req); cmd.connection = accessconnection;  odbcdatareader reader = cmd.executereader(); while (reader.read()) {     string[] row = new string[reader.fieldcount];      (int i=0; i<reader.fieldcount; i++) {         if (!reader.isdbnull(i)) { // added if visual studio             // getting empties strings, work fine numbers             row[i] = reader.getvalue(i).tostring();              // using getstring before, didn't work visual studio         }     }      output.add( row ); }  [...] return output; } 

and perform test request :

arraylist data = db.execute("select * materials");  foreach (string[] row in data) {     string line = "";     foreach (string s in row) {         line += s + " - ";     }     debug.log(line); // logging in unity3d console } 

and i'm getting :

1234 - 23.1 - - - 5678 - 12.9 - - - 

instead of :

1234 - 23.1 - string - string - 5678 - 12.9 - hello - world - 

why getting numbers , no strings , how can correct ?

edit : work fine visual studio 12, , windows 7, , edits had make making work visual studio didn't show improvement in unity program.

i have start saying don't have environment reproduce this; answer based on have expended in c# on windows sql server; namely buffers used underneath datareader reused memory efficiency.

when numbers converted strings, memory must allocated string, since no string exists. when tostring run on actual string, getting reference string still buried deep within datareader. memory gets reused next record.

the basic solution either processing on record record basis, or make copies of need loop around.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

methods - python can't use function in submodule -

c# - ErrorThe type or namespace name 'AxWMPLib' could not be found (are you missing a using directive or an assembly reference?) -