Hello,
When reading data from a SqlClient.SqlDa taReader in VB.NET 2005, I want to
display fiels that sometimes are empty.
sUser = CStr(rdUser("Na me") & Space(1) & CStr(rdUser("Fi rst_Name")
When the First_Name of a user is empty, I get an error telling me type
DBNull cannot be converted to String.
Is there a way of solving this problem?
Many thanks,
Michel 4 6280
On May 15, 10:33 am, "Michel Vanderbeke" <michel.vanderb ...@skynet.be>
wrote:
Hello,
When reading data from a SqlClient.SqlDa taReader in VB.NET 2005, I want to
display fiels that sometimes are empty.
sUser = CStr(rdUser("Na me") & Space(1) & CStr(rdUser("Fi rst_Name")
When the First_Name of a user is empty, I get an error telling me type
DBNull cannot be converted to String.
Is there a way of solving this problem?
Many thanks,
Michel
Instead of:
sUser = CStr(rdUser("Na me") & Space(1) & CStr(rdUser("Fi rst_Name")
Use:
sUser = rdUser("Name"). ToString() & Space(1) & rdUser("First
Name")
or even better (imo):
sUser = String.Format(" {0} {1}", rdUser("Name"). ToString(),
rdUser("First_N ame").ToString( ))
Thanks,
Seth Rowe
On May 15, 10:56 am, rowe_newsgroups <rowe_em...@yah oo.comwrote:
On May 15, 10:33 am, "Michel Vanderbeke" <michel.vanderb ...@skynet.be>
wrote:
Hello,
When reading data from a SqlClient.SqlDa taReader in VB.NET 2005, I want to
display fiels that sometimes are empty.
sUser = CStr(rdUser("Na me") & Space(1) & CStr(rdUser("Fi rst_Name")
When the First_Name of a user is empty, I get an error telling me type
DBNull cannot be converted to String.
Is there a way of solving this problem?
Many thanks,
Michel
Instead of:
sUser = CStr(rdUser("Na me") & Space(1) & CStr(rdUser("Fi rst_Name")
Use:
sUser = rdUser("Name"). ToString() & Space(1) & rdUser("First
Name")
or even better (imo):
sUser = String.Format(" {0} {1}", rdUser("Name"). ToString(),
rdUser("First_N ame").ToString( ))
Thanks,
Seth Rowe
sUser = rdUser("Name"). ToString() & Space(1) & rdUser("First
Name")
That should be:
sUser = rdUser("Name"). ToString() & Space(1) &
rdUser("First_N ame").ToString( )
Thanks,
Seth Rowe
"rowe_newsgroup s" <ro********@yah oo.comschrieb:
Instead of:
sUser = CStr(rdUser("Na me") & Space(1) & CStr(rdUser("Fi rst_Name")
Use:
sUser = rdUser("Name"). ToString() & Space(1) & rdUser("First
Name")
or even better (imo):
sUser = String.Format(" {0} {1}", rdUser("Name"). ToString(),
rdUser("First_N ame").ToString( ))
I am curious why this should be better. In addition, I'd write '... & " " &
....' instead of '... & Space(1) & ...'.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
On May 15, 4:32 pm, "Herfried K. Wagner [MVP]" <hirf-spam-me-
h...@gmx.atwrot e:
"rowe_newsgroup s" <rowe_em...@yah oo.comschrieb:
Instead of:
sUser = CStr(rdUser("Na me") & Space(1) & CStr(rdUser("Fi rst_Name")
Use:
sUser = rdUser("Name"). ToString() & Space(1) & rdUser("First
Name")
or even better (imo):
sUser = String.Format(" {0} {1}", rdUser("Name"). ToString(),
rdUser("First_N ame").ToString( ))
I am curious why this should be better. In addition, I'd write '... & " " &
...' instead of '... & Space(1) & ...'.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
I never said it was better - I was referring to String.Format - I too
would use & " ". I just left the code as the OP had it for
consistency.
Thanks,
Seth Rowe This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tim Johansson |
last post by:
I'm new to C++, and tried to start making a script that will shuffle an
array. Can someone please tell me what's wrong?
#include <iostream.h>
#include <string.h>
int main () {
srand(time(0));
int array_length;
int count;
|
by: Vijai Kalyan |
last post by:
Hello,
I have come back to C++ after a couple of years with Java so I am quite
rusty and this question may seem poor:
My platform is Windows XP with MSVC 7.1.
I have a class with a templatized conversion operator defined as
follows:
|
by: Martin |
last post by:
When I convert a program from VC6 to VC7 I get the
following linker error:
CVTRES : fatal error CVT1100: duplicate resource.
type:STRING, name:1686, language:0x0409
LINK : fatal error LNK1123: failure during conversion to
COFF: file invalid or corrupt
Duplicate resource...no problem! Except that I cannot
find that value anywhere!! No such string resource
|
by: dave |
last post by:
..
Line 38: Function FormatURL5(ByVal strArgument) As String
Line 39: If strArgument.length > 0 Then
Line 40: Return ("<INPUT id='mmmm' type='checkbox' value='"
& strArgument & "' onclick='parent.runThis('" & strArgument & "')'>")
Line 41: End If
|
by: Alphonse Giambrone |
last post by:
How can I convert a string to a different type based on another string or
other variable?
For instance, instead of
Dim i as Integer
i = ctype("1000", Integer)
I would like to do
| |
by: Bob Day |
last post by:
VS 2003, sql
How do you determine the data type of a column if its value is DBNull?
1)Table:
Column1 STRING non-nullable
2) Fill to a DataSet via DataAdapter
3) dim Data_Type_Is as object
|
by: ibiza |
last post by:
Hi all,
I'm using a business logic layer as described in this source code :
http://www.asp.net/QuickStart/util/srcview.aspx?path=~/aspnet/samples/data/GridViewObject.src&file=GridViewObject_cs\App_Code\AuthorsComponent.cs&lang=C%23+Source
It works very well until I encountered a small problem recently. When
it is time to bind the data from the db to my class representing an
"author" (let's say, for simplicity), what about if my row...
|
by: Chris |
last post by:
Hi again,
I want to read all the records of a table with 2 fields.
The problem is that some records have null value in the second field.
This code below works when all records have both fields fiilled, but gives
the error:
"Conversion from type 'DBNull' to type 'String' is not valid" when not.
.....
comd = New System.Data.OleDb.OleDbCommand("select name,lok from pc",
|
by: Sep410 |
last post by:
Hi all,
Please help me in this code:
txtLastNameFM.Text = IIf(dgFamilyMember.CurrentRow.Cells(3).Equals(System.DBNull.Value), "", dgFamilyMember.CurrentRow.Cells(3).Value)
this is an error I get:
Conversion from type 'DBNull' to type 'String' is not valid.
I know the value of the dgFamilyMember.CurrentRow.Cells(3).Value= null but the first part of the iif returns false! What is wrong here?
|
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,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |