I have integers in my database that can be null. I read them with
SqlDataReader and show them to Repeater. Since integer can not be null in
c#, I set null integer to -1. My project is 3-tier and it is very
complicated to check in data tier if it is null set -1, then in business
tier if it is -1 do not calculate with him and then in presentation tier "do
not show if it is -1". Is there any better solution for that? 5 1091
Hi Tomislav,
Maybe this link can help you: http://nullabletypes.sourceforge.net
--
Miha Markic [MVP C#] - RightHand .NET consulting & development
SLODUG - Slovene Developer Users Group www.rthand.com
"TomislaW" <to*********@hotmail.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl... I have integers in my database that can be null. I read them with SqlDataReader and show them to Repeater. Since integer can not be null in c#, I set null integer to -1. My project is 3-tier and it is very complicated to check in data tier if it is null set -1, then in business tier if it is -1 do not calculate with him and then in presentation tier "do not show if it is -1". Is there any better solution for that?
"TomislaW" <to*********@hotmail.com> wrote: I have integers in my database that can be null. [...] Since integer can not be null in c#, I set null integer to -1.
Use SqlInt32 (in System.Data.SqlTypes) and SqlInt32.Null.
P.
Hi,
No really, no matter what you do you will have to check for a "null" it
does not matter if the "null" is -1 or null.
You would have to do the same thing even if a null value was available, you
would have to check by null before any operation.
nothing that a simple if can't solve. :)
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"TomislaW" <to*********@hotmail.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl... I have integers in my database that can be null. I read them with SqlDataReader and show them to Repeater. Since integer can not be null in c#, I set null integer to -1. My project is 3-tier and it is very complicated to check in data tier if it is null set -1, then in business tier if it is -1 do not calculate with him and then in presentation tier "do not show if it is -1". Is there any better solution for that?
I decide to use SqlDataReader and asp:Repeater because of speed.
If I checking asp:Repeater on ItemDataBound I loose that speed, where to
check for nulls?
Is it better solution to build asp:Table in code behind?
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:e2**************@TK2MSFTNGP15.phx.gbl... Hi,
No really, no matter what you do you will have to check for a "null" it does not matter if the "null" is -1 or null.
You would have to do the same thing even if a null value was available, you would have to check by null before any operation.
nothing that a simple if can't solve. :)
Cheers,
-- Ignacio Machin, ignacio.machin AT dot.state.fl.us Florida Department Of Transportation "TomislaW" <to*********@hotmail.com> wrote in message news:%2******************@TK2MSFTNGP11.phx.gbl...I have integers in my database that can be null. I read them with SqlDataReader and show them to Repeater. Since integer can not be null in c#, I set null integer to -1. My project is 3-tier and it is very complicated to check in data tier if it is null set -1, then in business tier if it is -1 do not calculate with him and then in presentation tier "do not show if it is -1". Is there any better solution for that?
Hi, I decide to use SqlDataReader and asp:Repeater because of speed.
This has nothing to do with the subject at hand the problem will exist no
matter what you use to show your data.
If I checking asp:Repeater on ItemDataBound I loose that speed, where to check for nulls?
You could define a method that return the string you want to use to show
null, below is an example of such a construction from a datagrid
<ItemTemplate>
<asp:Label ID="lbl_inc_identification" Text=<%# FormatID(
Container.DataItem("inc_identification") )%> Runat="server"></asp:Label>
</ItemTemplate>
in the code behind:
protected string FormatID( object o)
{
if ( ( int)o == -1 )
return "N/A";
return o.ToString();
}
Is it better solution to build asp:Table in code behind?
Absolutly not !
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote in message news:e2**************@TK2MSFTNGP15.phx.gbl... Hi,
No really, no matter what you do you will have to check for a "null" it does not matter if the "null" is -1 or null.
You would have to do the same thing even if a null value was available, you would have to check by null before any operation.
nothing that a simple if can't solve. :)
Cheers,
-- Ignacio Machin, ignacio.machin AT dot.state.fl.us Florida Department Of Transportation "TomislaW" <to*********@hotmail.com> wrote in message news:%2******************@TK2MSFTNGP11.phx.gbl...I have integers in my database that can be null. I read them with SqlDataReader and show them to Repeater. Since integer can not be null in c#, I set null integer to -1. My project is 3-tier and it is very complicated to check in data tier if it is null set -1, then in business tier if it is -1 do not calculate with him and then in presentation tier "do not show if it is -1". Is there any better solution for that?
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: william |
last post by:
Hi
Whwn I select from database using ADO.NET, if the data is null value in database, how should I handle it
(string, integer, boolean type field)
Thank
willia
|
by: TomislaW |
last post by:
I have integers in my database that can be null. I read them with
SqlDataReader and show them to Repeater. Since integer can not be null in
c#, I set null integer to -1. My project is 3-tier and it...
|
by: TC |
last post by:
What does it mean for an integer to have a null value? I am trying to use
the DataView.Find method. That method has an integer return type which
contains the "index of the row in the DataView...
|
by: Woody Splawn |
last post by:
I have some code that looks like this:
Dim SSN, LName, FName, M As String
mySqlConnection = New SqlConnection(myConnectionString)
Dim sql_Command As New SqlCommand( _
"Select SSN, LName, FName,...
|
by: Řyvind Isaksen |
last post by:
I have a page with an optional integer-field, and one asp:calendar control.
I use a stored procedure to save the data in SQL Server.
When all fields contains data, the code works great! But if the...
| |
by: redpayne |
last post by:
Okay, I finally got this program to run according to what the book had us build it as. Now prof wants case 2 and case 3 to prompt again for input, check input to see if it is the correct type, then...
|
by: =?Utf-8?B?RG9u?= |
last post by:
Hello, I'm creating a web service that will allow people to enter their
contact information into a SQL Server table. I get it to work when I enter
all of the fields and press the invoke button,...
|
by: chutsu |
last post by:
I'm trying to compare between pointer and integer in an "IF" statement
how do I make this work?
if(patient.id != NULL){
}
Thanks
Chris
|
by: no1zson |
last post by:
I do not even know how to correctly ask this question.
I have an item field in the code I am about to post. Simple intger meant to be an item number for a cd. The user enters this number.
Over the...
|
by: matevzb |
last post by:
I've ran into some fishy code that, at first glance, is buggy, but it
seems to work correctly
and none of the compilers I've tried (five so far, on various systems)
gives any warnings.
The code:...
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |