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

Conversion from type 'DBNull' to type 'String' is not valid.

77
Hi all,
Please help me in this code:

txtLastNameFM.Text = IIf(dgFamilyMember.CurrentRow.Cells(3).Equals(Syst em.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?

I need to check the value of dgFamilyMember.CurrentRow.Cells(3).Value) to see if it is Null I need to fill txtlastname.text by "" otherwise I want to have the dgFamilyMember.CurrentRow.Cells(3).Value in that textbox.
Please help me.
Aug 8 '08 #1
3 3217
Curtis Rutland
3,256 Expert 2GB
You can't compare strings to DBNulls like that.
Aug 8 '08 #2
Sep410
77
I need to check the value of dgFamilyMember.CurrentRow.Cells(3).Value) to see if it is Null I need to fill txtlastname.text by "" otherwise I want to have the dgFamilyMember.CurrentRow.Cells(3).Value in that textbox.

Please help me.
Aug 8 '08 #3
Sep410
77
I found it.
I used IsDBNull(expression) before assigning to a string.
Aug 8 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

22
by: Christoph Boget | last post by:
I am getting an error (a few among many) for the following lines of code: retval.BrokerName = (( curRow == System.DBNull.Value ) ? SqlString.Null : (string)curRow ); retval.BrokerGroupId = ((...
7
by: | last post by:
Source Error: Line 173: sData(rownumber - 1, lcnt) = WhatCol.Value Line 174: End IF Line 175: If (sData(rownumber, lcnt) = sData(rownumber - 1, lcnt)) AND...
6
by: tshad | last post by:
The error I am getting is: ******************************************************************* Exception Details: System.InvalidCastException: Cast from type 'DBNull' to type 'String' is not...
3
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...
10
by: Bob | last post by:
I'm sure there's a good reason, I just haven't been able to think of it - why didn't MS allow "DBNull" values to simply be a null (Nothing)? Bob
2
by: ibiza | last post by:
Hi all, I'm using a business logic layer as described in this source code : ...
2
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...
4
by: SAL | last post by:
I'm sorry if this has been answered before but I didn't see it in a quick scan of the list. The following code is causing an error when the field is null: Error text: Conversion from type...
4
by: Michel Vanderbeke | last post by:
Hello, When reading data from a SqlClient.SqlDataReader in VB.NET 2005, I want to display fiels that sometimes are empty. sUser = CStr(rdUser("Name") & Space(1) & CStr(rdUser("First_Name") ...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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
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.