473,396 Members | 1,982 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,396 software developers and data experts.

smalldatetime Null in SQL for ASP.net Page

I have a database with a field used for an approval date set as a
smalldatetime. When the record is initially written it is intended to be
reviewd and approved. However until it is approved it has a null value,
which throws an error in the ASP page that is intended to be used to review
and update. The error is th DBNull to DateTime conversion error.

Any Suggestions?
Nov 19 '05 #1
3 2660
Show some snippets
"Robert Willhite" <Ro************@discussions.microsoft.com> wrote in
message news:AB**********************************@microsof t.com...
I have a database with a field used for an approval date set as a
smalldatetime. When the record is initially written it is intended to be
reviewd and approved. However until it is approved it has a null value,
which throws an error in the ASP page that is intended to be used to review and update. The error is th DBNull to DateTime conversion error.

Any Suggestions?

Nov 19 '05 #2
Patirck,

Thanks for the quick response. I actually found the solution and will
include it for any other searches

My old code was:

Request.ApprovedDate = drRequests.Item("ApprovedDate")

I wrote new code as follows:

If IsDBNull(drRequests.Item("ApprovedDate")) Then
Request.ApprovedDate = " "
Else
Request.ApprovedDate = Format(drRequests.Item("ApprovedDate"), "d")
End If
Thanks,

"Patirck Ige" wrote:
Show some snippets
"Robert Willhite" <Ro************@discussions.microsoft.com> wrote in
message news:AB**********************************@microsof t.com...
I have a database with a field used for an approval date set as a
smalldatetime. When the record is initially written it is intended to be
reviewd and approved. However until it is approved it has a null value,
which throws an error in the ASP page that is intended to be used to

review
and update. The error is th DBNull to DateTime conversion error.

Any Suggestions?


Nov 19 '05 #3
Good you got it working Robert
Patrick

"Robert Willhite" <Ro************@discussions.microsoft.com> wrote in
message news:21**********************************@microsof t.com...
Patirck,

Thanks for the quick response. I actually found the solution and will
include it for any other searches

My old code was:

Request.ApprovedDate = drRequests.Item("ApprovedDate")

I wrote new code as follows:

If IsDBNull(drRequests.Item("ApprovedDate")) Then
Request.ApprovedDate = " "
Else
Request.ApprovedDate = Format(drRequests.Item("ApprovedDate"), "d") End If
Thanks,

"Patirck Ige" wrote:
Show some snippets
"Robert Willhite" <Ro************@discussions.microsoft.com> wrote in
message news:AB**********************************@microsof t.com...
I have a database with a field used for an approval date set as a
smalldatetime. When the record is initially written it is intended to be reviewd and approved. However until it is approved it has a null value, which throws an error in the ASP page that is intended to be used to

review
and update. The error is th DBNull to DateTime conversion error.

Any Suggestions?


Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Joey Martin | last post by:
Please help. I have a ms sql table called data. Two fields, saledate(smalldatetime),saledatetext(nvarchar) I have dates (ex. 05/04/05) in the saledatetext, but I need this converted into...
7
by: Bostonasian | last post by:
I have a table that contains transactional data. Such as site view by whom, when, which template, etc, etc... Everytime when I pulled the report, hh:mm:ss never matters. Only breakdown by dates,...
1
by: Fred Nelson | last post by:
Hi: I'm a relative Newby writing my first vb.net web application that uses SQL SmallDateTime fields. I have some records that contain null values in the datetime fields and they return...
3
by: Pat | last post by:
i'm passing a string as a Date as value :- for example "23/07/1988" But when trying to insert it in a column with datatype "smalldatetime" i get an error The string was not recognized as a valid...
2
by: .Net Sports | last post by:
I'm using these to assign a variable to a smalldatetime object in sql server: dim todnews = DateTime.Today.ToString ( "d" ) 'connection string to server is on this line Dim strSQL2 as string...
5
by: Dimitri Furman | last post by:
This looks like a bug - hopefully somebody can explain what is actually happening. Using SQL Server 2000 SP4. Here's a repro script with comments: /* repro table */ CREATE TABLE dbo.T ( ID...
6
by: SQL Server | last post by:
I've been working this for a while. Kind of new to SQL Server functions and not seeing what I am doing wrong. I have this function CREATE FUNCTION dbo.test (@Group varchar(50)) RETURNS...
4
by: Normann | last post by:
I am creating a Stored Proc and I need to be able to select the last added row, now this should be made easier by the fact that I have a smalldatetime column in the table that is added every time a...
1
by: kkshansid | last post by:
here txtFields(14).Text="NULL" For i = 0 To maxfield adoPrimaryRS.Fields(i).Value = txtFields(i).Text Next i at i=14 this loop gives error plz help...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.