Solved

convert null to dbnull

Posted on 2013-06-06
2
344 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
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…
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…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

914 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

14 Experts available now in Live!

Get 1:1 Help Now