Timestamp and tableadapters (generated code)
Posted: Wed 01 Oct 2008 09:47
Hi,
I had a problem today that the tableadapter configuration wizard didn't generate the insertcommand. I have a timestamp column in my database which is declared "not null default current_timestamp" as per default MySQL behaviour. I did not want to include the timestamp column in my select/insert/update since the generated tableadapter automatically defines the column with "AllowDBNull = false". I do not want to specify a value myself when I add new rows to the datatable but I want MySQL to automatically insert the value.
I guess the wizard could not create the insertcommand since columns set to not null in the database was not included in the select statement.
My workaround right now is that I manually change the AllowDBNull value to true for all timestamp columns, but this a potential source for bugs later if I forget to do this after an update of the tableadapter generation.
Any chance of a setting specifically for timestamps to choose that they don't need to be included in the select but the insertcommand will still be created? OR if running MySQL in MaxDB mode I believe it will be closer to the ANSI SQL correct behaviour, timestamp is then similar to DateTime column and are not updated automatically unless specified to do so in the table definition like: "ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
Any thought about this issue?
PS. Right now I don't dare changing the MySQL mode to MaxDB and spend a lot of time checking every part of every system using MySQL here...
I had a problem today that the tableadapter configuration wizard didn't generate the insertcommand. I have a timestamp column in my database which is declared "not null default current_timestamp" as per default MySQL behaviour. I did not want to include the timestamp column in my select/insert/update since the generated tableadapter automatically defines the column with "AllowDBNull = false". I do not want to specify a value myself when I add new rows to the datatable but I want MySQL to automatically insert the value.
I guess the wizard could not create the insertcommand since columns set to not null in the database was not included in the select statement.
My workaround right now is that I manually change the AllowDBNull value to true for all timestamp columns, but this a potential source for bugs later if I forget to do this after an update of the tableadapter generation.
Any chance of a setting specifically for timestamps to choose that they don't need to be included in the select but the insertcommand will still be created? OR if running MySQL in MaxDB mode I believe it will be closer to the ANSI SQL correct behaviour, timestamp is then similar to DateTime column and are not updated automatically unless specified to do so in the table definition like: "ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
Any thought about this issue?
PS. Right now I don't dare changing the MySQL mode to MaxDB and spend a lot of time checking every part of every system using MySQL here...