Hello,
I am calling a stored procedure to update my table.
If one of the date on the screen left empty, I need to send date as null.
Since MyDate=”” gives error in asp.net, how should I do this?
Thanks,
Jim. 8 3252
Either dont pass it and let the DB set it to null or use the DBValue.Null
--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"JIM.H." <JI**@discussio ns.microsoft.co m> wrote in message
news:ED******** *************** ***********@mic rosoft.com... Hello, I am calling a stored procedure to update my table. If one of the date on the screen left empty, I need to send date as null. Since MyDate="" gives error in asp.net, how should I do this? Thanks, Jim.
Hey Curt!
I'll bet you meant DBNull.Value <grin>
"Curt_C [MVP]" <software_AT_da rkfalz.com> wrote in message
news:uS******** ********@TK2MSF TNGP11.phx.gbl. .. Either dont pass it and let the DB set it to null or use the DBValue.Null
Should I do this in asp.net? MyDate=DBNull.V alue is not recognized in my
application. I did Imports System.Object, it is still teh same.
"Ken Cox [Microsoft MVP]" wrote: Hey Curt!
I'll bet you meant DBNull.Value <grin> "Curt_C [MVP]" <software_AT_da rkfalz.com> wrote in message news:uS******** ********@TK2MSF TNGP11.phx.gbl. .. Either dont pass it and let the DB set it to null or use the DBValue.Null
Jim,
You could set the parameter in the stored procedure to have a
default value of null, then if the user doesn't enter a date in the field
you can still pass the parameter with the date information, just don't set
the value of the parameter and the stored procedure will automatically use
null.
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
"JIM.H." <JI**@discussio ns.microsoft.co m> wrote in message
news:ED******** *************** ***********@mic rosoft.com... Hello, I am calling a stored procedure to update my table. If one of the date on the screen left empty, I need to send date as null. Since MyDate="" gives error in asp.net, how should I do this? Thanks, Jim.
The Date variable type cannot be null. It must have a value.
Most people use Date.MinValue (or Date.MaxValue) to represent a null date in
their code.
Example:
Dim MyDate as Date = Date.MinValue
As for inserting it in the database, the other guys already specified that
DBNull.Value is what you'll want to use.
--
I hope this helps,
Steve C. Orr, MCSD, MVP http://SteveOrr.net
"JIM.H." <JI**@discussio ns.microsoft.co m> wrote in message
news:ED******** *************** ***********@mic rosoft.com... Hello, I am calling a stored procedure to update my table. If one of the date on the screen left empty, I need to send date as null. Since MyDate="" gives error in asp.net, how should I do this? Thanks, Jim.
I did Date = Date.MinValue and Date has only time value liek 12:00:00 and
when I try to call stored procedure it gives me out of range. Does
Date.MinValue give a default date? If yes, what is it? I am using 1/1/1950 as
default date.
"Steve C. Orr [MVP, MCSD]" wrote: The Date variable type cannot be null. It must have a value. Most people use Date.MinValue (or Date.MaxValue) to represent a null date in their code.
Example: Dim MyDate as Date = Date.MinValue
As for inserting it in the database, the other guys already specified that DBNull.Value is what you'll want to use.
-- I hope this helps, Steve C. Orr, MCSD, MVP http://SteveOrr.net "JIM.H." <JI**@discussio ns.microsoft.co m> wrote in message news:ED******** *************** ***********@mic rosoft.com... Hello, I am calling a stored procedure to update my table. If one of the date on the screen left empty, I need to send date as null. Since MyDate="" gives error in asp.net, how should I do this? Thanks, Jim.
Date.MinValue = January 1, 0001.
This is why the stored procedure chokes on it.
You need to check for this special value and instead pass DBNull.Value to
the stored procedure.
--
I hope this helps,
Steve C. Orr, MCSD, MVP http://SteveOrr.net
"JIM.H." <JI**@discussio ns.microsoft.co m> wrote in message
news:95******** *************** ***********@mic rosoft.com... I did Date = Date.MinValue and Date has only time value liek 12:00:00 and when I try to call stored procedure it gives me out of range. Does Date.MinValue give a default date? If yes, what is it? I am using 1/1/1950 as default date.
"Steve C. Orr [MVP, MCSD]" wrote:
The Date variable type cannot be null. It must have a value. Most people use Date.MinValue (or Date.MaxValue) to represent a null date in their code.
Example: Dim MyDate as Date = Date.MinValue
As for inserting it in the database, the other guys already specified that DBNull.Value is what you'll want to use.
-- I hope this helps, Steve C. Orr, MCSD, MVP http://SteveOrr.net "JIM.H." <JI**@discussio ns.microsoft.co m> wrote in message news:ED******** *************** ***********@mic rosoft.com... > Hello, > I am calling a stored procedure to update my table. > If one of the date on the screen left empty, I need to send date as > null. > Since MyDate="" gives error in asp.net, how should I do this? > Thanks, > Jim. >
Hello JIM.H.,
If you need to pass it to a stored procedure, and you require a value, you
can use SqlDateTime.Min Value. If you allow nulls, just use DBNull.Value.
--
Matt Berther http://www.mattberther.com I did Date = Date.MinValue and Date has only time value liek 12:00:00 and when I try to call stored procedure it gives me out of range. Does Date.MinValue give a default date? If yes, what is it? I am using 1/1/1950 as default date.
"Steve C. Orr [MVP, MCSD]" wrote:
The Date variable type cannot be null. It must have a value. Most people use Date.MinValue (or Date.MaxValue) to represent a null date in their code. Example: Dim MyDate as Date = Date.MinValue As for inserting it in the database, the other guys already specified that DBNull.Value is what you'll want to use.
-- I hope this helps, Steve C. Orr, MCSD, MVP http://SteveOrr.net "JIM.H." <JI**@discussio ns.microsoft.co m> wrote in message news:ED******** *************** ***********@mic rosoft.com...
Hello, I am calling a stored procedure to update my table. If one of the date on the screen left empty, I need to send date as null. Since MyDate="" gives error in asp.net, how should I do this? Thanks, Jim. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dominique Javet |
last post by:
Hello,
I'm new to php and mysql and I use Dreamweaver MX 2004, so sorry for this
"newbie" question... I've found no answer in the forum ...
I've a date problem with my formular. In my mysql DB my filed "date" in
table "experience" is like this: Y-m-d (2002-07-23).
My fied`date` is date, NOT NULL with no default entry
My form read well the date data depending the id, (pe. 30.02.2003), but when
I submit a new date, I receive as result...
|
by: zaceti |
last post by:
I'm new to MySQL and I am having a problem selecting the highest
valued date/time for a particular day. Here is the table structure:
+--------------+-----------------+-----+----+--------+--------------+
| Field | Type | Null| Key| Default|Extra |
+--------------+-----------------+-----+----+--------+--------------+
| id | int(10) unsigned| | PRI| NULL |auto_increment|
| timestamp | datetime ...
|
by: Thomas R. Hummel |
last post by:
Hello,
I am importing data that lists rates for particular coverages for a
particular period of time. Unfortunately, the data source isn't very
clean. I've come up with some rules that I think will work to clean the
data, but I'm having trouble putting those rules into efficient SQL.
The table that I'm dealing with has just under 9M rows and I may need
to use similar logic on an even larger table, so I'd like something
that can be made...
|
by: Dr John Stockton |
last post by:
It has appeared that ancient sources give a method for Numeric Date
Validation that involves numerous tests to determine month length;
versions are often posted by incomers here. That sort of code seems
unnecessarily long.
For some while, the following approach has been given here :-
function ValidDate(y, m, d) { // m = 0..11 ; y m d integers, y!=0
|
by: Stewart Allen |
last post by:
I'm trying to filter a table that has 2 date fields, the first date will
always have a value but the second will only occasionally has a value. Each
date field also has a corresponding text field to record the record's
status.
Sample data:
*tblTest*
Model Parts CDate CStatus RDate RStatus
616 $359.79 03-Nov-03 C
| |
by: Ken |
last post by:
I wrote a function to use in queries that takes a date and adds or
subtracts a certain length time and then returns the new value. There
are times when my function needs to return Null values.
Function DateCalc (blah...) As Variant
Do Stuff...
If Not IsNull(varNewDate) Then
DateCalc = varNewDate
End If
End Function
|
by: Nimmy |
last post by:
Hi,
I have a file which has different dates, I want to scanf them as CHAR and
convert them to DATE format, how can I do this?
Thanks
|
by: Rethish |
last post by:
Hi All,
I am developing an application in VB.net. I am using .Net Datetime
picker control to manage the date. But I am not able to assign null/Empty
value to the control. I found the property "Checked" to work with this
control..But I cannot use this property for making null dates..
Is there any way to solve this problem?.
Expecting any help or suggestions?
Regards,
|
by: Assimalyst |
last post by:
Hi,
I have a working script that converts a dd/mm/yyyy text box date entry
to yyyy/mm/dd and compares it to the current date, giving an error
through an asp.net custom validator, it is as follows:
function doDateCheckNow(source, args)
{
var oDate = document.getElementById(source.controltovalidate); //
dd/mm/yyyy
|
by: ice |
last post by:
Hello,
I have a couple of tables. The client tables and the contacted
tables.
I am not sure how to start on this, what I need is a way to query all
my clients
then show any client that the last visit and or called day is greater
than 30 days.
Now it gets confusing, Suppose the client was visited more than 30 days
ago
but was called only 10 days ago, I really would like to have this
|
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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...
|
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 projectplanning, coding, testing, and deploymentwithout 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...
|
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 presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |