Datareader and Access Null fields and Memoshttp://forums.asp.net/t/758055.aspx/1?Datareader+and+Access+Null+fields+and+MemosSat, 27 Nov 2004 19:51:51 -0500758055758055http://forums.asp.net/p/758055/758055.aspx/1?Datareader+and+Access+Null+fields+and+MemosDatareader and Access Null fields and Memos Hi All I'm reading an Access database and some fields have null values. If I use MyReader.GetString() I get a cast error. Also how do I read meno fields? best regards B 2004-11-27T17:29:11-05:00758104http://forums.asp.net/p/758055/758104.aspx/1?Re+Datareader+and+Access+Null+fields+and+MemosRe: Datareader and Access Null fields and Memos You can do your access inside a try/catch, or alternately, just do this: MyReader("MyField").ToString() which I believe will result in an empty string (have not tried it just now...). 2004-11-27T18:55:47-05:00758120http://forums.asp.net/p/758055/758120.aspx/1?Re+Datareader+and+Access+Null+fields+and+MemosRe: Datareader and Access Null fields and Memos ::I'm reading an Access database and some fields have null values. If I use ::MyReader.GetString() I get a cast error. Then, simply, do not use GetString (), but GetObject (); And check against null. Do NOT set up a try/catch for this - VERY bad practice, for performance and code size. 2004-11-27T19:12:22-05:00758123http://forums.asp.net/p/758055/758123.aspx/1?Re+Datareader+and+Access+Null+fields+and+MemosRe: Datareader and Access Null fields and Memos I guess I should have clarified. If the null is an exceptional circumstance, then the try/catch is OK. If a large percentage of the fields are null, then likely explicitly checking for null before casting will be better. I created helper functions to do just that for me. 2004-11-27T19:15:55-05:00758136http://forums.asp.net/p/758055/758136.aspx/1?Re+Datareader+and+Access+Null+fields+and+MemosRe: Datareader and Access Null fields and Memos Douglas Thanks for that - it works a treat. As he memo field will usually be null this seems to be the better option. Thanks to you all for your replies/help B 2004-11-27T19:41:42-05:00