VB.NET + NAV Web service: Set date to "empty"

dpardom
Member Posts: 74
Hi.
How can I set a date field to "empty" using VB.NET and Nav web services?
My code:
Tried with Nothing/null, system.dbnull, date.minvalue, "1753-01-01"... but nothing seems to work.
Thanks.
Solution.
Hotfix, as seen in blog's comments.
I tested it and works. Now SqlDateTime.MinValue is the "null" date for Nav.
How can I set a date field to "empty" using VB.NET and Nav web services?
My code:
Dim a As New NAV.Job_Service a.UseDefaultCredentials = True Dim b As NAV.Job b = a.Read("a-job-no") b.some_date_field = [color=#FF0000]???[/color] a.Update(b)
Tried with Nothing/null, system.dbnull, date.minvalue, "1753-01-01"... but nothing seems to work.
Thanks.
Solution.
Luc Van Dyck wrote:Vjeko has written a blog posting about the 0D bug: http://navigateintosuccess.com/blog/bug ... services-2
Hotfix, as seen in blog's comments.
Soren January 12, 2012 at 23:19
KB2606541 – https://mbs2.microsoft.com/Knowledgebas ... us$2606541
Seems like this should be the fix for it. But i have not tested it.
I tested it and works. Now SqlDateTime.MinValue is the "null" date for Nav.
0
Answers
-
the 0D value in NAV is '1753-01-01 00:00:00:000'. In .NET the functions expect DateTime variable.-Mihail- [MCTS]0
-
Sorry, I don't understand very well what do you mean.
In .NET, it expects a "Date" variable.
With cdate("01/01/1753") it throws: "The * table contains a field with a date value that cannot be used with SQL Server".
\:D/0 -
dpardom wrote:Sorry, I don't understand very well what do you mean.
In .NET, it expects a "Date" variable.
With cdate("01/01/1753") it throws: "The * table contains a field with a date value that cannot be used with SQL Server".
\:D/
Did you even read mihail's post. He gave you the exact answer. ](*,)David Singleton0 -
I read it again, but can't understand.
Also, as I said, .NET function expects a "Date", not a "Datetime".
Can you explain it, please?0 -
No, you might wrote a method which expects Date variable. If you publish a function from NAV the Date parameter is represented as DateTime in .NET-Mihail- [MCTS]0
-
Thanks for helping, mihail.mihail_kolev wrote:No, you might wrote a method which expects Date variable.
I published a function in a codeunit with a "date" parameter and a "datetime" parameter. Both are the same from .NET (both are "date" .NET type), and can't use sqldatetime.minvalue (wich seems to be the "null" value for Nav) with none ot them.
The problem seems to be that '1753-01-01 00:00:00:000' is not converted to '0D'. Maybe a regionalization problem? We got other problems related with dates and decimals due to diferences in representation.mihail_kolev wrote:If you publish a function from NAV the Date parameter is represented as DateTime in .NET
I don't understand how to modify a date through a Nav web services without publishing a function. (ie, a page with its "modify" function or a function in a codeunit)
Please, check the workaround I added to the first post. Maybe it helps.
Thanks again.0 -
Vjeko has written a blog posting about the 0D bug: http://navigateintosuccess.com/blog/bug ... services-2No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)0
-
Thank you very much, Luc Van Dyck. That was the problem. I copied the answer to the first post.
Thank you too, mihail_kolev, for trying to help.
And for David Singleton an (optional) advice: Don't give such answers, even if you are right.
See you.0 -
dpardom wrote:Hotfix, as seen in blog's comments.Soren January 12, 2012 at 23:19
KB2606541 – https://mbs2.microsoft.com/Knowledgebas ... us$2606541
Seems like this should be the fix for it. But i have not tested it.
I tested it and works. Now SqlDateTime.MinValue is the "null" date for Nav.
Hi,
1.
Has this hotfix been retracted?? if i click on download I cannot select the hotfix.
2.
Is this the latest hotfix or can I use a newer one to fix all problems?0 -
1.- You must login with one of the four methods listed in the page. Then click "View and request hotfix downloads", and provide an email address to receive the hotfix link.
2.- Sorry, I don't know.0 -
dpardom wrote:1.- You must login with one of the four methods listed in the page. Then click "View and request hotfix downloads", and provide an email address to receive the hotfix link.
2.- Sorry, I don't know.0 -
We're converting a website from using a custom wrapper that was created some years ago to use Navision Web Services to read/write data from/to Dyanamics NAV/Navision.
The system is also being upgraded from 2009r2 to 2013r2.
However, we're experiencing the same issue when trying to update a record so that it has a "null" date.
When we set the value to either SqlDateTime.MinValue or CDate("1/1/1753") we get the same error as the OP.
It seems that the link to the "fix" is no longer available, but I believe I found the post by looking through the sites archives. However after looking at the post is doesn't seem to help when using web services. We're accessing the data through a published Page rather than a CodeUnit, and it seems like a huge overhead to call a function in a CodeUnit just to do something the page should already be able to do.
However, that's the approach we're going to have to take until this gets fixed properly.
For reference and for anyone else experiencing the same issue, the suggested solution is to extend the page with an extension CodeUnit and have a function for each date field you're likely to want to clear (set to a null date in Nav). You can then pass in the keys fields to identify the correct record, then set the date to 0D in code.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions