HOW DO I: Insert nulls into SQL dateTime field stored in SQL DB from a web UI textbox

I’m looking for feedback on the Best/Right way to Insert nulls into SQL dateTime field in SQL DB from a web UI textbox.

 

 Option 1:     Presently implemented:

 Dim dtFollowUpDate = IIf(dtDateFollowUp.Text = "", System.Data.SqlTypes.SqlDateTime.Null, dtDateFollowUp.Text)

Although ithis does what is needed it generates the following inner exception Angry [:@]

 

ParamValue    {System.Data.SqlTypes.SqlDateTime} Object[System.Data.SqlTypes.SqlDateTime] {System.Data.SqlTypes.SqlDateTime}            System.Data.SqlTypes.SqlDateTimeDayTicks  

<error: an exception of type: {System.Data.SqlTypes.SqlNullValueException} occurred>            Integer IsNull   True     Boolean

 

Option 2:

Dim dtFollowUpDate = IIf(dtDateFollowUp.Text = "", System.DBNull.Value, dtDateFollowUp.Text)

 No exceptions, no problems that I have seen yet.

 

Option 3:

Dim dtNull As System.Data.SqlTypes.INullable

Dim dtFollowUpDate = IIf(dtDateFollowUp.Text = "", dtNull, dtDateFollowUp.Text)

 No exceptions, no problems that I have seen yet.

 

Any advice would be greatly appreciated!  Idea [Idea]

 

Thanks Big Smile [:D]

 

Craig

CTARP2

 

0
ctarp2
3/29/2006 4:01:33 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

1 Replies
932 Views

Similar Articles

[PageSpeed] 40

This is what I have used and it works
***********************
Dinakar Nethi
Life is short. Enjoy it.
***********************
0
ndinakar
3/29/2006 7:28:45 PM
Reply:

Similar Artilces:

how do i insert data into sql server using data from textboxes and sql connection and sql command
anyone can give me a simple explaination and code.. Thanx in advance Take a look @ Sample Code: How to add...Sushila Bowalekar PatelVisual ASP/ASP.NET MVPhttp://weblogs.asp.net/sushilasb There are a lot of tutorials out there, but I know they can be a bit confusing as they all approach things slightly differently. Basically a nice simple version would go like this:' *** First set up your connectionDim conConnection As New SqlConnection("server=servername;database=yourdatabase;uid=yourname;pwd=yourpassword;")' *** This line takes care of your sommand text and command connection in one ...

Insert SQL on Sql Command
i'm using an sql command for insert query it looks like this cmd=new sqlcommand("insert into tblname values('" & textbox1.text & "')",cn) cmd.executereader the problem is if i type a singlequote or double quote an error is throwing,invalid syntax .... how can i s'rt out it with out using a sql stored procedure thanks in advance PrasantHI think therefore i'mvPras© Hi, try replacing the single quotes present in your input with double single quotes ... example below: string sqlInput = textbox1.text.Replace("'","''...

Can I store a data field from SQL DB to a TextBox?
I have a SQL table call tblTransaction and one of the field is the Cost. Now I have a Page.aspx with a textbox that I am trying to have it display the Cost data from SQL for a selected row so that I can update that cost. How can I do that? Thanks for help. Hi,You need to use SQLCommand take a look at http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.aspx Regards,Viktar KarpachMCTS .NET 2.0 Web Application, MCPD Web DeveloperASP.NET C# Technical Blog Well if you simply want to populate the textbox based on a conditional query, you could use something like this....

Strange difference between SQL from .Net and SQL within stored proc
Hi, I am trying to fill a DataGrid with random records from my database. It thought I had found a way to randomly select records using SQL. So I built a stored procedure in Access and sure enough, it returns a random set of records. Whe I tried to call this from my app, it kept returning the same set of records. So I copied and pasted the SQL into the app (code below) but it made no difference. Could anyone tell me why this wouldn't work? <%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %><%@ Import Namespace="System.Data" %><%@ Import Namespace="...

Storing textbox null value to the bigint field of SQL Sever Database
Hi, I have a data entry form with  a couple of fields that are not NOT REQUIRED.Data type of both fields is bigint.So when they are empty,I get an error.I'm using Convert.int64() to convert the values.It works fine if there is a value.I also tried storing values without using the Convert function but still I get an error.Please Help! try doing the convert if the value is not null.***********************Dinakar NethiLife is short. Enjoy it.***********************   When it's not null, the convert function works fine. Sorry I meant to suggest writing an IF loop before you...

Attach SQL DB to SQL Server 2005 using VB.Net
Is there any way to attach a SQL DB to SQL Server 2005 using VB.Net?  If so can you also set security? Can you rephrase your question? Attach SQL DB from which version of SQL server ? Look up books online for sp_attachdb and sp_detachdb.***********************Dinakar NethiLife is short. Enjoy it.*********************** I have a DB that was created in SQL Server 2005.  I have a website that displays data from systems all over the world.  Each system sends it's data to it's own DB.  The customer can then go to a website and see the data at real time.  What ...

Working in VB.Net 2005 inserting NULL into a field in Microsoft SQL Server 2005
I am update/inserting records threw a web form in vb.net. I need to insert 'NULL'  into my microsoft sql server database.  I am not talking about the below line of code where website is the name of my paramater.  If i do that it will just place a blank into that field in the database.  If i dont enter anything into that textbox I want it to to say NULL in that field. So if I go into the actual table in the SQL Server Management Studio and look at the website field of the recored I just added or updated and did not type anything into the web site textbo...

SQL SERVER 2000: In which format the datetime will be stored in sql server 2000?
Hi All, I would like to know, how the datetime will be stored in the sqlserver datetime column. Because some time i am giving the date in dd/mm/yyyy and sometime mm/dd/yyyy. while give the date in mm/dd/yyyy works fine but not in the another case. and also while i execute a query on query analyser it shows the datetime in yyyy/mm/dd format. So anyone can please tell me how the dates will be stored in the datetime column of sqlserver database? Thanks in Advance. Regards, Dhanasekaran. G Storing of datetime depends upon the globalization setting. Normally the date time is stor...

How can I update an MS SQL 7.0 datetime field with embedded sql
I have a datetime field in MS Sql 7.0 named Revised_Date. I can update this date with my datawindow but I can't update it with embedded sql. I have tried the following which doesn't work UPDATE dbo.employees SET revised_date = date() ; produces invalid function error UPDATE dbo.employees SET revised_date = 2000-07-31 ; which yeilds 05/17/05 which is incorrect date ld_date time ldt_datetime ld_date = today ldt_date = datetime(ld_date) UPDATE dbo.employees SET revised_date = :ldt_date; which yields error How can I accomplish this ? T...

BCP Sybase SQL Server db to SQL Anywhere db?
Anyone, I am searching for an automated way to take an entire Sybase SQL Server db on a Unix server and get it into a Sybase SQL Anywhere db on my laptop. I dont feel like going table by table through the Pipeline not to mention that I have RI proplems with this approach as well. Ideally, I would like to have explained to me a way to perform a BCP from the Unix SQL Server world into the windows based SQL Anywhere world. If this is even possible. The model itself is not as important as the data because we use ERwin and I am able to forward engineer the model onto the SQL Anywhe...

BCP Sybase SQL Server db to SQL Anywhere db?
Anyone, I am searching for an automated way to take an entire Sybase SQL Server db on a Unix server and get it into a Sybase SQL Anywhere db on my laptop. I dont feel like going table by table through the Pipeline not to mention that I have RI proplems with this approach as well. Ideally, I would like to have explained to me a way to perform a BCP from the Unix SQL Server world into the windows based SQL Anywhere world. If this is even possible. The model itself is not as important as the data because we use ERwin and I am able to forward engineer the model onto the SQL Anywhe...

Problem inserting sql query into database float datatype field using SQL Transaction
I have this problem of inserting my query into database field. My code is as of below. The @AVERAGESCORE parameter is derived from Dim averagescore As Single = (122 * 1 + 159 * 2 + 18 * 3 + 3 * 4 + 0 * 5) / (122 + 159 + 18 + 3 + 0) and the value returned is  (averagescore.toString("0.00")) However, I have error inserting the averagescore variable into a field of datatype float during the transaction. I have no problems when using non transactional sql insert methods. What could be the problem?   Try Dim i As Integer ...

linking a sql field to point to the value of another sql field
is it possible to create hyperlinks in powerbuilder such that if you retrieve two fields from a database.. and want to display the first field on the screen and have it link to the value of the other field (when clicked) which is actually a URL address, you can? any help will be appreciated. thank you! ...

SQL Express to SQL ?
I am developing a site using the express edition of all tools (VWD and SQL Express).  I want to use GoDaddy hosting and was wondering if I will be able to effectively put my SQL database and website up on their hosting even though it was developed via Express edition of Microsoft programs?...

Web resources about - HOW DO I: Insert nulls into SQL dateTime field stored in SQL DB from a web UI textbox - asp.net.sql-datasource

Is there a JQuery plugin to convert UTC datetimes to local user timezone?
If I have a tag: &lt;span class="utctime"&gt;2010-01-01 11:30 PM&lt;/span&gt; I would like a jquery script or plug in to convert every utctime ...


Targetprocess 3.7.3: Epic unit for Bug/Story cards, new DateTime functions in Webhook plugin
Webhook plugin supports new DateTime functions AddDays(DateTime date, int days) – Returns a new date with the number of days added. The number ...

Common Pitfalls when working with DateTime’s
In .NET, the DateTime structure provides us wonderful functionality, but this seemingly simple structure can cause a lot of headaches if you ...

Parsing Twitter Date format to .Net DateTime
Recently when I needed to parse the twitter datetime format into a .Net DateTime I found this post on the web showing how to do it. However, ...

C Sharp (programming language) - Wikipedia, the free encyclopedia
(pronounced see sharp ) is a multi-paradigm programming language encompassing strong typing , imperative , declarative , functional , generic ...

1753 - Wikipedia, the free encyclopedia
Language: English Afrikaans አማርኛ العربية Aragonés Asturianu Aymar aru Azərbaycanca বাংলা Bân-lâm-gú Basa Banyumasan Беларуская ‪Беларуская (тарашкевіца)‬ ...

Coded Smorgasbord: Schizophrenic Haiku Comments and More
... writes Malcom StandardResponse UnSubscribeNewsletterUserAccount( string opTinGUID,string email, string sellingRegion, string source, DateTime ...

Limburg.be - Welkom op de site van de provincie Limburg - Welkom_op_de_site_van_de_provincie_Limburg
visit wonen werken leven ontspannen infopunt home op trefwoord contactpersonen wegwijs sitemap print deze pagina Je bent hier: limburg.be Contact ...

Simples Ideias. Por Nando Vieira.
Simples Ideias Siga-me no Twitter Junho/2012 Usando o Vagrant como ambiente de desenvolvimento no Windows http://simplesideias.com.br/usando ...

Resources last updated: 12/17/2015 4:56:36 PM