You are currently viewing the BOOK: Professional Visual Studio 2008 ISBN: 978-0-470-22988-0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
I'm using this to update a date/time field, and at runtime, it can't find the function. Is this function a SQL/server function? I'm using Access as my database.
I've even tried NOW()... data type mis-match error
Thanks Imar, yes I tried Date() and the 'query builder' gives an error of:
'Your entry cannot be converted to a valid date/time value.'
I've tried 'TO_Date()'... runtime not found
I've tried several permutations there of and either gotten 'runtime not found' OR the same as above.
I'm using a combination of a datagridview(minimal columns) and a 'detail view'(all columns, with the update-date in a label, since "I" want to set it and not the user)
Is there a way to get control of the datarow and hence the date-update field, before the bindingsource.endedit and the tableadapter.update run? (it's the update that's giving me grief; for about 2 weeks now).
Thanks
How are you using the Date() method in your SQL code? This works for me:
INSERT INTO MyTable ( CreateDate) VALUES (Date());
When you are assigning a value from the .NET world, have you tried System.DateTime.Now?
Other than that, hard to suggest something. I am not too experienced with desktop databinding. Maybe posting your relevant code sheds some light or brings somebody else with the answer to this thread.
Imar,
Thanks again. I did try the 'NOW()' function... I didn't use system.datetime.now in the query builder, but it's an idea... I will try it.
However, I have created a work-around. I created another updatequery and using the records 'autonumber' as the 'where' criteria, I'm able to force the record to update. The way I gain control of the data is that, since I'm displaying all the data anyway, I just validate and modify the 'textboxes' data, and the update uses the now() query as 'just another parameter'. The problem I had before was, I was trying to use NOW() in the 'query-builder' process... there it does not seem to work.
I can't paste a screen shot, but it's where you can modify the 'dataset-designed' query, and type in an 'expression' in the 'Set Value' column... anyway. Like I said I've made a work-around and here's my code that does work: