473,378 Members | 1,539 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,378 software developers and data experts.

joining three strings where one is null?

VMI
In my datatable, I'm retrieving three fields from an Access table and I
concatenate them into one string. Then I put this information in another
datacolumn that I added to the datatable (with DataColumn.Expression).
Unfortunately, when one's a Null, apparently it makes the whole string a
Null and that's what's seen in the grid.
This is what I use:

DataColumn col_input = new DataColumn("Input");
col_input.DataType = System.Type.GetType("System.String");
col_input.Expression = "InFBU + ' \r\n' + InDel + '\r\n' + InCity + ' '" +
"+ InState + ' ' + InZIP + '-' + InAddon";

But in most cases, InAddon will be null so, when I display col_input in my
grid, it only displays the value null.
What can I do to avoid this?
Nov 16 '05 #1
2 3044
VMI,

You want to use the ISNULL expression, like so:

col_input.Expression = "ISNULL(InFBU, '') + ' \r\n' + ISNULL(InDel, '') +
'\r\n' + ISNULL(InCity, '') + ' '" + "+ ISNULL(InState, '') + ' ' +
ISNULL(InZIP, '') + '-' + ISNULL(InAddon, '')";

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"VMI" <vo******@yahoo.com> wrote in message
news:eA**************@TK2MSFTNGP09.phx.gbl...
In my datatable, I'm retrieving three fields from an Access table and I
concatenate them into one string. Then I put this information in another
datacolumn that I added to the datatable (with DataColumn.Expression).
Unfortunately, when one's a Null, apparently it makes the whole string a
Null and that's what's seen in the grid.
This is what I use:

DataColumn col_input = new DataColumn("Input");
col_input.DataType = System.Type.GetType("System.String");
col_input.Expression = "InFBU + ' \r\n' + InDel + '\r\n' + InCity + ' '" +
"+ InState + ' ' + InZIP + '-' + InAddon";

But in most cases, InAddon will be null so, when I display col_input in my
grid, it only displays the value null.
What can I do to avoid this?

Nov 16 '05 #2
VMI
It worked great.

Thanks again.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:eF**************@TK2MSFTNGP11.phx.gbl...
VMI,

You want to use the ISNULL expression, like so:

col_input.Expression = "ISNULL(InFBU, '') + ' \r\n' + ISNULL(InDel, '') +
'\r\n' + ISNULL(InCity, '') + ' '" + "+ ISNULL(InState, '') + ' ' +
ISNULL(InZIP, '') + '-' + ISNULL(InAddon, '')";

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"VMI" <vo******@yahoo.com> wrote in message
news:eA**************@TK2MSFTNGP09.phx.gbl...
In my datatable, I'm retrieving three fields from an Access table and I
concatenate them into one string. Then I put this information in another
datacolumn that I added to the datatable (with DataColumn.Expression).
Unfortunately, when one's a Null, apparently it makes the whole string a
Null and that's what's seen in the grid.
This is what I use:

DataColumn col_input = new DataColumn("Input");
col_input.DataType = System.Type.GetType("System.String");
col_input.Expression = "InFBU + ' \r\n' + InDel + '\r\n' + InCity + ' '"
+
"+ InState + ' ' + InZIP + '-' + InAddon";

But in most cases, InAddon will be null so, when I display col_input in
my grid, it only displays the value null.
What can I do to avoid this?


Nov 16 '05 #3

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

Similar topics

1
by: Joe | last post by:
I've got 3 columns in a mysql database that I am trying to join. I'm using CONCAT(), but it's giving me NULL results. This has worked for me before ... What am I doing wrong? Here's a straight...
4
by: Job Lot | last post by:
Is there anyway of Joining two or more DataTable with similar structure? I have three DataTables with following structures Data, AmountB/F, Repayments, InterestCharged and AmountC/F i want...
2
by: Shaggy Dragon | last post by:
Hi there, been looking for a solution to this for some time now. I've a UNION query that produces a table called AllSecurities: SELECT SecurityNumber, Book AS AllSecurities FROM Trades UNION...
1
by: stewart palmer via AccessMonster.com | last post by:
What is wrong with the following: UPDATE enq SET enq.DUP = Left$(!,3)&Left$(!,3)&Right$(!,3)&Left$(!,2)&left$(!,5); According to ACCESS 97 Help, using & instead of + should overcome the problem...
1
by: Steve C | last post by:
Hi, I'm having problems constructing a nested join. It's quite complex, so here's a simplfied example of the problem. Any thoughts on what I'm doig wrong - or if I've got the whole approach...
4
by: Rnt6872 | last post by:
Table A Table B BOL# B_BOL# Chargeback# Hi All, I have been struggling with this for...
1
by: lee | last post by:
Hi This is a dumb question as I know it's fairly easy but I cant seem to find an example after two hours of searching. In a stored procedure I'm trying to build up a string eg, (the...
7
by: sam.barker0 | last post by:
Hi, I tried to use the java approach to join 2 strings int w=0; string z="blah " + w + "blah " but this gives me an error but this works string z("blah"); z+=w;
3
by: nickvans | last post by:
Hello everyone, I am new to SQL Server, and am having trouble joining several SELECT statements together. I have three SQL Select statements that do separate count operations to get the status...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.