Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

[RESOLVED] Not IsNothing

$
0
0
Hi,

In my insert statement I have the following code;

Code:

        .AddWithValue("@LicenceEffectiveDate", IIf(Not IsNothing(txtliceffdate.Text), txtliceffdate.Text, DBNull.Value))
Reason: To insert a NULL value inacse the date was not inserted and the textbox is blank.

At runtime and insert function called - and the textbox is empty it inserts to the table a 01/01/01/ 00:00:00 datetime.

Now, as a test I removed the NOT infront of IsNothing and entered a date to the textbox and insert function called.

Result: It inserrted a NULL value to the table at the backend..

Now, it appears the NOT is not forcing the NULL value to be inserted if blank to the database..

Any help and suggestions pls...

Thanks

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>