So I'm having more database issues. This one I think is a bit more straight forward. I have an Access database and in it I have a table with several columns of data. I want to get the Maximum value of a column, from that table. One of my columns gives me an issue with this and I'm not sure why. Here is my code:
You can see reading Voltage and Power work just fine, but trying to read current returns an error. Searching on NI's site this error is used for a lot of things and it is usually because of a 32 or 64 bit issue but in this case the read worked on two previous columns that are also an I32 but the third time it doesn't. It also fails right away when you try Current first so it is likely something with this column. Is there something I can check? I opened it in Access and was able to make a query with the Query Wizard to find the min max of current. The database it self is over 1GB so posted won't be possible. Even pruning it might be an issue. Any suggestions? Thanks.
Solved! Go to Solution.
I'm guessing this probably won't help since you are getting some data back but it may be worth a shot investigating (if you haven't already).
Yeah I didn't link to that in my first post, but I mentioned it saying that there was an error with 32 and 64 bit applications. But if it returns fine once, and twice for two other columns, I'm guessing that means the problem is not with the application call but something with that column. It is the only one I've seen that behaves this way too.
My bad. Guess that's what I get for not reading the entire post.
I have never used the ACE DB provider when communicating with mdb files, but rather the Jet provider. See if that makes a difference.
1. What happens if you only make this SQL call on the current column?
2. Can you make other SQL calls on this column without error?
3. Can yoou make other SQL calls on all three columns without error?
Could it be that Current is a reserved word in Access?
@aputman Thanks for the suggestion still new with the database toolkit. I tried the Microsoft.Jet.OLEDB.4.0 provider and it had the same issue.
@PatrickLye I mentioned this in my first post but maybe it wasn't clear. If you call just Current it fails. I didn't test other queries because...
@dkfire Bingo. I renamed it Current2 and it worked. I then changed it back to Current but added brackets [ and ] around the column name and it worked fine. Is this common practice to add these backets on all queries? I noticed some have spaces in the column names and brackets were needed.
I don't what is common way to do.
Normally I know up front what the names of the columns are, and can adjust my query to that.
I try to avoid names with spaces, for the same reason, to make sure that a query works on all platforms.
I tend to bracket column and table names in all cases, just to be safe. Makes things a lot easier, eventhough the SQL string itself doesn't get that much more readable from it. But you get used to it and then it is really not a problem anymore. Also it is usually a good idea to add the schema name too. It is usually overkill, but makes it absolutely clear on which schema the query is meant to work on.