473,795 Members | 2,954 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

vb.net, MSSQL, and null dates

I have an application where a database entity that progresses through a
cycle. As it completes a step along the cycle, a todays date is assign to
one of the date columns in the table row. However at the beginning of the
cycle many of the dates hold null values.

Is there a simple way that I can read a date with a null value into a class
object I have created and turn around a write it back out to the table with
again with a null value?

How do people handle null date values coming into VB? My only option has
been to convert it to some fictious date value and program accordingly. Any
suggestions? Any online resources?

Thanks!
Nov 21 '05 #1
4 6987
I use stored procedures or sql as strings to read and write.
Stored procedures are my preference, but not as flexible as building a
sql string.
Either way, there's a SQL insert or update string somewhere.
You can insert NULL by missing the field out the list, assuming there
is no default value on it.
You can update a field to null by setting it to NULL.
"Update mytable set myfield = NULL where...."

You can also leave a field as null by not updating the field ( or row
).

Nov 21 '05 #2
if you want to set a field to null in VB.NET code, set the field equal to
System.DbNull.V alue.

You can also check if a value is null using this same object.

Hope it helps
Chris
"Lakota61" <La******@discu ssions.microsof t.com> wrote in message
news:41******** *************** ***********@mic rosoft.com...
I have an application where a database entity that progresses through a
cycle. As it completes a step along the cycle, a todays date is assign to
one of the date columns in the table row. However at the beginning of the
cycle many of the dates hold null values.

Is there a simple way that I can read a date with a null value into a
class
object I have created and turn around a write it back out to the table
with
again with a null value?

How do people handle null date values coming into VB? My only option has
been to convert it to some fictious date value and program accordingly.
Any
suggestions? Any online resources?

Thanks!

Nov 21 '05 #3
I have tried to use that method but variables defined with a date will not
accept system.dbnull.v alue. It says that it can not be converted to a date.

Thanks

"Chris, Master of All Things Insignifican" wrote:
if you want to set a field to null in VB.NET code, set the field equal to
System.DbNull.V alue.

You can also check if a value is null using this same object.

Hope it helps
Chris
"Lakota61" <La******@discu ssions.microsof t.com> wrote in message
news:41******** *************** ***********@mic rosoft.com...
I have an application where a database entity that progresses through a
cycle. As it completes a step along the cycle, a todays date is assign to
one of the date columns in the table row. However at the beginning of the
cycle many of the dates hold null values.

Is there a simple way that I can read a date with a null value into a
class
object I have created and turn around a write it back out to the table
with
again with a null value?

How do people handle null date values coming into VB? My only option has
been to convert it to some fictious date value and program accordingly.
Any
suggestions? Any online resources?

Thanks!


Nov 21 '05 #4
Lakota,

Are you using a datatable or a datareader, probably it is than easier to
answer you.
Or maybe even a datatable with binding to a control, what is again a little
bit else, where it differs if it is a "datasource " kind of control or a
databinding kind of control.

Maybe you can tell that?

Cor

"Lakota61" <La******@discu ssions.microsof t.com>
I have tried to use that method but variables defined with a date will not
accept system.dbnull.v alue. It says that it can not be converted to a
date.

Thanks

"Chris, Master of All Things Insignifican" wrote:
if you want to set a field to null in VB.NET code, set the field equal to
System.DbNull.V alue.

You can also check if a value is null using this same object.

Hope it helps
Chris
"Lakota61" <La******@discu ssions.microsof t.com> wrote in message
news:41******** *************** ***********@mic rosoft.com...
>I have an application where a database entity that progresses through a
> cycle. As it completes a step along the cycle, a todays date is assign
> to
> one of the date columns in the table row. However at the beginning of
> the
> cycle many of the dates hold null values.
>
> Is there a simple way that I can read a date with a null value into a
> class
> object I have created and turn around a write it back out to the table
> with
> again with a null value?
>
> How do people handle null date values coming into VB? My only option
> has
> been to convert it to some fictious date value and program accordingly.
> Any
> suggestions? Any online resources?
>
> Thanks!


Nov 21 '05 #5

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

Similar topics

7
23877
by: mj | last post by:
Hello, thanks for the help. I am running a WinXP Pro w/ SP2 (my home computer, with ZoneAlarm firewall) Apache 2.0.52 MySQL 4.1.7 PHP 5.1.0-dev I have developed a PHP/MySQL web app that tracks jobs for me, and we
5
1620
by: Markon | last post by:
Hello I have recently decided to upgrade my programs to enable users to have mssql databases instead of access. I have since then run into many incompatibilities between their sql: access has IIF(x>y,a,b) whereas mssql hase case when (this already means hundreds of changes in queries) it does not have format(number,'#,##0.00') or format(date,'dd.MM.yyyy') but most surprising is following: access allows this while mssql reports error...
14
2473
by: Kukurydz | last post by:
I've got such problem: My database is stored on MSSQL Server. I have to write reports for it in MSAccess. I've got a problem with creating a query which will select records from MSSQL table with date and time values from given range. The difficulty is mainly caused by the fact, that Date and Time is stored in separate rows as String . I've tried to use CDate() function in my query, but it worked well only during tests on small table (about...
8
10410
by: Lyn | last post by:
I am trying to get my head around the concept of default, special or empty values that appear in Access VBA, depending on data type. The Access Help is not much (help), and the manual that I have is not much help here either. Googling has given me a little help. This is my current understanding -- I would appreciate any comments or corrections... "" -- this means an empty string when applied to String data type, and also to Variant...
0
1094
by: Rookie Card | last post by:
Issue - Reformating the Dates in ASP.NET from a MSSQL Database that has <NULL> values in a SmallDateTime Field to read "Dec 8, 2000" instead of "12/8/2000 12:00:00 AM" (As you might already know "DateTime.Parse" will throw an exception when it comes accross a <NULL> date value so some logic has to be written.
2
9298
by: jblankenburg | last post by:
Please help! I am hunting high and low for an equivalent function for MSSQL's DATENAME function. Here's the spec on the function from MSSQL's Books Online: DATENAME Returns a character string representing the specified datepart of the specified date.
7
3209
by: Mark Knochen | last post by:
Hallo, i have a MS SQL Database with some tables with textfields. in the textfields are long strings ... but i cant get the full string from the table ... i get only ca. 8000 chars ... Mark
0
7949
by: m3rajk | last post by:
I've recently become the defacto DBA of two MSSQL databases at work because I am the only one with SQL experience. I have been asked to do some tasks with the databases but this requires and understanding of their structure. I cannot find anything akin to MySQL's mysqldump for mssql and have been looking for that among other help in being able to use my MySQL experience as a base for learning MSSQL. I have spent a few days (8 to 9 hours per day)...
2
2625
by: akronymn | last post by:
I have an mssql database that I need to migrate to mysql. For some reason though any queries to any columns of type datetime are returned in French in the following format: 7/avr/2004 14:00 This also includes all the text of an SQL dump which not surprisingly makes mysql unable to read the dump from the MSSQL db. I've checked that my windows regional setting is set to English. I'm at a loss as to why this is happening or how to fix it. I...
0
9673
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10448
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10167
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9046
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2922
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.