Bug #3809 all fields are reported as not updatable
Submitted: 18 May 2004 11:19 Modified: 11 Sep 2007 18:09
Reporter: Adrian Sandor Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:3.51.07, 3.51.17 OS:Windows (Windows XP)
Assigned to: Jess Balint CPU Architecture:Any
Tags: ADO, ODBC5-RC

[18 May 2004 11:19] Adrian Sandor
Description:
Using ASP, ADO and a system DSN to connect to MySQL 4.0.18
I open a recordset for writing (with adLockPessimistic) and none of the fields have the adFldUpdatable attribute. Normally all fields, maybe excepting auto-increments and calculated fields, should have it.

How to repeat:
//javascript asp
rst.Open("SELECT * FROM table", cnn, 0 /*adOpenForwardOnly*/, 2 /*adLockPessimistic*/);
Response.Write(rst.Fields(x /*any field*/).Attributes&4 /*adLockPessimistic*/)

It will display 0 for MySQL; for other databases, e.g. Access, it displays 4 for all fields except autonumbers.
[18 May 2004 11:28] Adrian Sandor
I noticed that the fields have the adFldUnknownUpdatable attribute instead. Hmm...
[18 May 2004 11:32] Adrian Sandor
And I made a mistake in a comment:
instead of
Response.Write(rst.Fields(x /*any field*/).Attributes&4 /*adLockPessimistic*/)
it should be
Response.Write(rst.Fields(x /*any field*/).Attributes&4 /*adFldUpdatable*/)
[9 Aug 2004 22:04] Mark Matthews
Please test with 3.51.08 or .09. If bug still present, please attach testcase you used to confirm it.
[23 Aug 2004 12:17] Adrian Sandor
I reproduced the bug with 3.51.09
The test case is the same one, included in the original message.
[26 Oct 2004 23:23] MySQL Verification Team
I was able to get the same behavior using ADO + Access 2003 and
the Connector/ODBC 3.51.09.
[27 Jul 2007 20:26] Tonci Grgin
This is still a bug, at least on my box.
[11 Sep 2007 18:09] Jim Winstead
As Adrian noticed (back in 2004), we are returning SQL_ATTR_READWRITE_UNKNOWN for SQL_DESC_UPDATABLE (which ADO maps to adFldUnknownUpdatable). We're returning this for all fields unless we know they can't be updated.

This is what the MSDN docs have to say about SQL_DESC_UPDATABLE: "Whether a column is updatable can be based on the data type, user privileges, and the definition of the result set itself. If it is unclear whether a column is updatable, SQL_ATTR_READWRITE_UNKNOWN should be returned."

The best we can really do is identify some situations when the column is definitely not updatable, and we do return SQL_ATTR_READONLY in those cases.