473,834 Members | 1,640 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to handle nulls in a construcor

Hi, Im real new at this so be gentle. I want to create a customer
object based on the results of an sql query to the customers table, ie
one object per row, and then add each of these objects to an arraylist
and then on to some datbinding in a listbox. Therefore, for each row
sent back by the datareader, I try to create the new customer object
and pass all the data in the row as part of the constructor. But, I
declared the data fields in the customer class to be the same data type
as those in the database but null causes a problem. To get round the
problem, I just made addtional New constuctors for each column which
may have nulls and then set the datfields to empty strings inside the
constructor and thus not pass the null data at all from the datreader
row. But that is a lot of kludge to test for null before the call to
the constructor so that i call the right constructor. i tried to have
constructors which accepts nulls as arguments and then set the private
data fields to empty strings from there but ran in to cast problems
*(esp with strict ON) in the call to the constructor.
What is the right way to create objects whose private data fields are
of one data type , but whose arguments might be null when they are
instantiated and how should null arguments be specified.

Nov 21 '05 #1
0 886

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

Similar topics

0
1907
by: Dan Perlman | last post by:
From: "Dan Perlman" <dan@dpci.NOSPAM.us> Subject: ODBC creating nulls? Date: Friday, July 09, 2004 10:43 AM Hi, Below is my VB6 code that writes data from an Access 2000 table to a PG table. The " & "" " on the right of each line should prevent nulls from being
2
2366
by: Steve Walker | last post by:
Hi all. I've been tasked with "speeding up" a mid-sized production system. It is riddled with nulls... "IsNull" all over the procs, etc. Is it worth it to get rid of the nulls and not allow them in the columns anymore? If so, how to go about removing the nulls with a script?
3
2015
by: aaj | last post by:
Hi I am probably going to regret asking this because I'm sure you are going to tell me my design is bad 8-) ah well we all have to learn.... anyway I often use Nulls as a marker to see if certain tasks have been completed. A typical example would be a column say invoice_value
6
28303
by: mike | last post by:
I'm doing what I thought was a simple GROUP BY summary of fairly simple data and the my numbers aren't working out Some results are showing up <NULL> when I know the data is in the database I'm no SQL expert, but if I'm summing (SUM) multiple fields and adding them together in my SELECT how does SUM handle Null? In some situations a single column in a single row is Null but and it's part of a larger GROUP BY and SUM and from looking...
1
1306
by: gelangov | last post by:
I already asked this question; however, I am giving all the details now: We get large files(millions of records) and we need to load it into our tables using import export wizard. Some of the fields in the file can be Null and so we are forced to create table with fields that allow Nulls with default ''. However when we insert data into these tables it puts Null in those fields even though we have a default '' (I do not think we have...
1
2075
by: PST | last post by:
Here's a problem I'm trying to deal with: I'm working on a Frontpage 2000 website for a boat handicapping system, built in Access 97. What I'm trying to accomplish is: The user enters a boat name in a text field OR a sail number in a text field, and gets the desired boat record back (an exact match).
13
2391
by: jt | last post by:
I can't seem to find a way to concatenate strings that have nulls within the string. I have a string that I need another string that has nulls in it and what to append the 2nd string, 3 string and so forth to the 1st string. Any ideas how to go about this? Thanks,
6
5463
by: Cliff72 | last post by:
I need to fill in the nulls in the batch field the value from the record immediately preceding the null one ie replace the nulls with the preceding value until I hit a record with a value in it--then hold the next value through the next set of nulls, and so on. See example below: I wanna copy down batch "IMR138" in record ID 1, all the way to ID 10. Then copy down batch "7138" all the way to ID 20 and so on....
7
13489
by: tshad | last post by:
Can you handle nullable string vb.net 2.0? You can with Integer but I get an error when I try to do a Dim s as Nullable (Of String) Now strings are a nullable type but it can't handle: fn.FormName = dbReader("FormName")
0
9797
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9644
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10793
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9331
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7757
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5626
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5793
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3977
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3081
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.