473,399 Members | 3,302 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

date in web service

I have a webservice that accepts a date which ultimately submits to a sql server 2008 database with a data type of date (allows null values), however the infopath form that submits that date sometimes might be blank or null.

I can't figure out how to check if the date variable the web service is accepting (datStartDate) is blank or null from the form, and if null/blank then submit a Null value to the database, if not null send the date the form is sending.

I have tried Nullable(Of Date) check on that variable and also hasvalue but can't get it to work.

thanks for you help

this is hte code i am currently using and works great if i actually submit a value

Expand|Select|Wrap|Line Numbers
  1. <WebMethod(Description:="")> _
  2.     Public Function SubmitAppData(ByVal strAppID As String, ByVal datStartDate As Date) As Integer
  3.  
  4.         Dim sqlCon As New SqlConnection()
  5.         Dim sqlCmd As New SqlCommand()
  6.  
  7.  
  8.         'sqlCon.ConnectionString = "connection string info"
  9.         sqlCon.ConnectionString = connStr
  10.  
  11.         If sqlCon.State = ConnectionState.Closed Then
  12.             sqlCon.Open()
  13.         End If
  14.         sqlCmd.CommandText = "usp_SendValues"
  15.         sqlCmd.Connection = sqlCon
  16.         sqlCmd.CommandType = CommandType.StoredProcedure
  17.  
  18.         'Dim maxDate As Nullable(Of Date)
  19.         'maxDate = datDRLastTestDate
  20.  
  21.         Dim Parameter1 As SqlParameter = New SqlParameter("@AppID", strAppID)
  22.         Dim Parameter2 As SqlParameter = New SqlParameter("@StartDate", datStartDate)
  23.  
  24.         Parameter1.Direction = ParameterDirection.Input
  25.         Parameter2.Direction = ParameterDirection.Output
  26.  
  27.         sqlCmd.Parameters.Add(Parameter0)
  28.         sqlCmd.Parameters.Add(Parameter1)
  29.  
  30.  
  31.         Dim dr As SqlDataReader
  32.         dr = sqlCmd.ExecuteReader()
  33.  
  34.         sqlCon.Close()
  35.  
  36.     Dim returnValue as String = "Hello"
  37.  
  38.         Return returnValue
  39.  
  40.     End Function
Apr 26 '10 #1

✓ answered by Frinavale

I'm not entirely sure I understand what your problem is exactly...but..

A DateTime is a primitive/value type which means that it always has a value. It can't be null/nothing.

You can check to see if the DateTime contains the same value as a New DateTime to see if "nothing" was supplied. From this you can determine whether you parameter to DBNull.Value (if the user provided nothing) or to the date that the user provided.

-Frinny

2 2311
Frinavale
9,735 Expert Mod 8TB
I'm not entirely sure I understand what your problem is exactly...but..

A DateTime is a primitive/value type which means that it always has a value. It can't be null/nothing.

You can check to see if the DateTime contains the same value as a New DateTime to see if "nothing" was supplied. From this you can determine whether you parameter to DBNull.Value (if the user provided nothing) or to the date that the user provided.

-Frinny
Apr 27 '10 #2
thanks for the help i got it figured out, i changed it to text and was able to pass the null or date to the web service.
Jun 23 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: MattB | last post by:
I've hit a snag with an application I wrote because of the differing date formats in different countries. It's a set of pages that make calls to a COM object that I have wrapped in a web...
1
by: harsha reddy | last post by:
Dear All, I have a front end form which has a couple of dropdown menus which select data from the database based on the value selected, the stored procedure which the program accesses outputs...
7
by: CheezIt2831 | last post by:
hello, I have 5 tables(Alpha, Bravo, Charlie, Service, Trans). What i am trying to do is be able to select a start date and ending date for a report and include fields from the 5 tables. this is my...
4
by: perryclisbee via AccessMonster.com | last post by:
I have dates of service for several people that range all over each month. ie: patient had dates of service of: 7/3/2006, 7/24/2006 and 7/25/2006. I need to create a new field via a query that...
7
by: =?Utf-8?B?U3R1?= | last post by:
I have a ASP.NET Ajax app (using client library) calling ASP.NET Ajax-enabled web services. We are making use of the javascript proxies generated by ASP.NET Ajax. The problem we have is that the...
5
by: Stan | last post by:
I am working on a database in ACCESS 2003. Six of the fields provide for entry of service dates 1 to 6 progressively recording when the client was serviced. The data type is Date/Time. I need to...
2
by: andrewbb | last post by:
Occasionally I had been getting a 30-60 second delay when starting a Windows service written in .NET. Today I stumbled upon a way to reproduce it without fail: Set the system date to the 31st...
2
by: wevans | last post by:
I have 3 tables, Customer, Offsite Service and service. I need to create a sales report/query based on the results of the user input, which is a date range. I've got it working great with two of the...
5
by: HowHow | last post by:
First time using crosstab query because tired of creating queries and put them together in one query (such a stupid thing to do :D). Not sure how it works still. I have link table called...
25
smithj14
by: smithj14 | last post by:
I have a form that has an option group (fraReports) which holds a list of reports to print. This part works fine. I select a report name and click print and that report opens. Now I want to add a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.