Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

convert null to dbnull

Posted on 2013-06-06
2
Medium Priority
?
359 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

722 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