Solved

convert null to dbnull

Posted on 2013-06-06
2
343 Views
Last Modified: 2013-06-07
Hi,

I have a form which has object, string and numbers.

I need a function to pass values of these to return DBNULL if value is null else return the value as is. Looking for a single function to handle all this

Any help ?
0
Comment
Question by:GRChandrashekar
2 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 39225154
numbers cannot be null unless its Nullable like Nullable(Of Integer) and so on.
for object and string u can check if null and return DBNull.
    Private Function Validate(val As Object) As Object
        If val Is Nothing Then
            Return System.DBNull.Value
        End If
        Return val
    End Function

Open in new window

0
 
LVL 19

Expert Comment

by:Shahan Ayyub
ID: 39225649
hi!

Something like this would help you:

Public Function IsNull(obj As Object) As object
	Return IIF(obj.Equals(Nothing), DBNull.Value, obj)
End Function

Open in new window

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now