Wrox Programmer Forums
|
BOOK: Professional Visual Studio 2008 ISBN: 978-0-470-22988-0
This is the forum to discuss the Wrox book Professional Visual Studio 2008 by Nick Randolph, David Gardner; ISBN: 9780470229880
Welcome to the p2p.wrox.com Forums.

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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 25th, 2009, 04:18 PM
Registered User
 
Join Date: Aug 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy GetDate() function in Chp 21

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

Can you recommend anything to fix this?

Thanks
Rick
 
Old August 25th, 2009, 04:31 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yes, it's SQL Server specific. Have you tried Date()?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old August 25th, 2009, 04:40 PM
Registered User
 
Join Date: Aug 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old August 25th, 2009, 06:00 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

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.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old August 25th, 2009, 06:26 PM
Registered User
 
Join Date: Aug 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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:

Quote:
Me.TblObserverTableAdapter.MyUpdateQuery(Ob_IDText Box.Text, Ob_FNameTextBox.Text, Ob_MIDTextBox.Text, Ob_LNameTextBox.Text, Ob_PasswordTextBox.Text, tempphone, tempcell, Ob_EmailTextBox.Text, Org_IDTextBox.Text, Now(), Ob_TypeTextBox.Text, Ob_AutoNumberTextBox.Text)
Rick





Similar Threads
Thread Thread Starter Forum Replies Last Post
getdate Not Working ~Bean~ SQL Server 2000 4 September 7th, 2005 11:31 PM
GETDATE? drachx SQL Server 2000 2 February 17th, 2005 08:05 AM
Using GETDATE in an In-Line function Mitch SQL Server 2000 13 March 25th, 2004 08:46 AM
seconds missing in getdate() stufflebeem SQL Server 2000 1 October 24th, 2003 04:52 PM
GETDATE() dose not......... arshad mahmood SQL Server 2000 2 August 19th, 2003 07:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.