473,387 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

System.Nullable 2.0 Framework

The 2.0 Framework has a new type called System.Nullable. This allows
something to Not exist, basically you can pass 'Nothing' to a method whose
parameters as System.Nullable.

Im looking at table adapters ; you know those clever little things which
allow you to contrsuct methods for manipulating data use this. So a method
might be declared someting like this.

Private Sub myMethod(ByVal myYear As System.Nullable(Of Integer), ByVal
myweek As System.Nullable(Of Integer))

End Sub

My question is. How to I translate this into a practical method call for a
value which may or may not exits. Lets say we have two text boxes.
yearTextBox and weekTextBox.

How to I assign an integer value or nothing depending on if the box is
emtpy, because you cant assign nothing to an integer. I dont want multiple
call lines to the one method, just one.

--
Goofy

--
Goofy
Dec 20 '06 #1
3 1997

Goofy wrote:
The 2.0 Framework has a new type called System.Nullable. This allows
something to Not exist, basically you can pass 'Nothing' to a method whose
parameters as System.Nullable.

Im looking at table adapters ; you know those clever little things which
allow you to contrsuct methods for manipulating data use this. So a method
might be declared someting like this.

Private Sub myMethod(ByVal myYear As System.Nullable(Of Integer), ByVal
myweek As System.Nullable(Of Integer))

End Sub

My question is. How to I translate this into a practical method call for a
value which may or may not exits. Lets say we have two text boxes.
yearTextBox and weekTextBox.

How to I assign an integer value or nothing depending on if the box is
emtpy, because you cant assign nothing to an integer. I dont want multiple
call lines to the one method, just one.

--
Goofy
I think that an object of type Nullable(Of Integer) can hold either an
integer value, or Nothing. To access the value of it use th Value
property. If you are worried about getting Nothing from it, use the
HasValue property which will tell you if the Nullable object stores a
value, or stores Nothing.

Inside your myMethod, you could say:

if myYear.HasValue then
myYearTextBox.text = myYear.Value
else
myYearTextBox.text = ""
end if

Dec 20 '06 #2
Well, thats doesent quite work because the sql where clause is like this.

WHERE ((week_no=@week_no) or (@week_no is null)) AND ( (pyear=@pyear) or
(@pyear is null) )
so the TableAdapterMethod needs to see either Nothing or a Value. So my
question is how do I call this on one line.
<lo*********@gmail.comwrote in message
news:11**********************@a3g2000cwd.googlegro ups.com...
>
Goofy wrote:
>The 2.0 Framework has a new type called System.Nullable. This allows
something to Not exist, basically you can pass 'Nothing' to a method
whose
parameters as System.Nullable.

Im looking at table adapters ; you know those clever little things which
allow you to contrsuct methods for manipulating data use this. So a
method
might be declared someting like this.

Private Sub myMethod(ByVal myYear As System.Nullable(Of Integer), ByVal
myweek As System.Nullable(Of Integer))

End Sub

My question is. How to I translate this into a practical method call for
a
value which may or may not exits. Lets say we have two text boxes.
yearTextBox and weekTextBox.

How to I assign an integer value or nothing depending on if the box is
emtpy, because you cant assign nothing to an integer. I dont want
multiple
call lines to the one method, just one.

--
Goofy

I think that an object of type Nullable(Of Integer) can hold either an
integer value, or Nothing. To access the value of it use th Value
property. If you are worried about getting Nothing from it, use the
HasValue property which will tell you if the Nullable object stores a
value, or stores Nothing.

Inside your myMethod, you could say:

if myYear.HasValue then
myYearTextBox.text = myYear.Value
else
myYearTextBox.text = ""
end if

Dec 20 '06 #3
Got it.

Dim year As System.Nullable(Of Single)

Dim week As System.Nullable(Of Integer)

"Goofy" <me@mine.comwrote in message
news:Oi**************@TK2MSFTNGP04.phx.gbl...
Well, thats doesent quite work because the sql where clause is like this.

WHERE ((week_no=@week_no) or (@week_no is null)) AND ( (pyear=@pyear)
or (@pyear is null) )
so the TableAdapterMethod needs to see either Nothing or a Value. So my
question is how do I call this on one line.
<lo*********@gmail.comwrote in message
news:11**********************@a3g2000cwd.googlegro ups.com...
>>
Goofy wrote:
>>The 2.0 Framework has a new type called System.Nullable. This allows
something to Not exist, basically you can pass 'Nothing' to a method
whose
parameters as System.Nullable.

Im looking at table adapters ; you know those clever little things which
allow you to contrsuct methods for manipulating data use this. So a
method
might be declared someting like this.

Private Sub myMethod(ByVal myYear As System.Nullable(Of Integer), ByVal
myweek As System.Nullable(Of Integer))

End Sub

My question is. How to I translate this into a practical method call for
a
value which may or may not exits. Lets say we have two text boxes.
yearTextBox and weekTextBox.

How to I assign an integer value or nothing depending on if the box is
emtpy, because you cant assign nothing to an integer. I dont want
multiple
call lines to the one method, just one.

--
Goofy

I think that an object of type Nullable(Of Integer) can hold either an
integer value, or Nothing. To access the value of it use th Value
property. If you are worried about getting Nothing from it, use the
HasValue property which will tell you if the Nullable object stores a
value, or stores Nothing.

Inside your myMethod, you could say:

if myYear.HasValue then
myYearTextBox.text = myYear.Value
else
myYearTextBox.text = ""
end if


Dec 20 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: John Wood | last post by:
I was just looking at an article about using nullable value types. (value types that can effectively have no value and not be set). The syntax is to append a question-mark to the value type in...
8
by: shawnk | last post by:
Given several nullable boolean flags; bool? l_flg_01 = true; bool? l_flg_02 = false; bool? l_flg_03 = true; bool? l_result_flg = null; I would have liked...
0
by: Larry Lard | last post by:
There seems to be something a bit lacking in the way the dataset designer thing deals (or rather doesn't) with nullable fields in VS2005. Maybe it's cos I'm using VB2005 Express (which is variously...
0
by: pranesh.nayak | last post by:
Hello Group, (tech: C#, VS2005) I'm facing a problem in passing Nullable<DateTimeto a webservice. Below is code in webservice wrapper (reference.cs) used set/get date. When i set date value...
3
by: MobileBoy36 | last post by:
Hi all, Nullable types were announced as new handy stuff in .NET 2.0 But it seems like the datareader doesn't support nullable types. You have still to check for "IsDbNull". So, are Nullable...
4
by: Goofy | last post by:
The 2.0 Framework has a new type called System.Nullable. This allows something to Not exist, basically you can pass 'Nothing' to a method whose parameters as System.Nullable. Im looking at table...
3
by: Sugandh Jain | last post by:
Hi, I am using property like this.. private DateTime? _propName; public DateTime? PropName { get { return _propName; }
20
by: sarnold | last post by:
Hello, I am proposing to create two new keywords for C, 'notnull' and 'nullable'. Their meaning is a sort of 'design by contract', ensuring some rules are verified at compile-time. It should...
0
by: ata | last post by:
Hi, I would like to know whether the *Nullable fields* are already supported under ASP.NET Web Services that have been created using .NET Framework 3.5? As you know, you were not allowed to use...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.