Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Convert NULL to EMPTY string

Posted on 2007-11-19
5
Medium Priority
?
10,688 Views
Last Modified: 2010-09-07
I am using an SQL database in my ASP.NET application. I want to edit/insert new entries to the database using detailsview control. I might not enter information into all the fields, for example I might have a record only with FirtsName, but no LastName and no Phone. For the purpose of searching the database later I do not allow NULL as a field entry. Obviously, when I am trying to insert/edit a record with some empty fields I have an error. How can I convert NULL type data fields from detailsview into EMPTY strings before writing data to the SQL database? Thank you.

0
Comment
Question by:lmgregg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 7

Accepted Solution

by:
nisarkhan earned 2000 total points
ID: 20314154
isnull(column_name, empty_string)

note: empty_string means: ''    <<<<(single quote  single quote)

isnull(column_name, '')
0
 
LVL 14

Expert Comment

by:ptakja
ID: 20314181
Or, you can replace empty_string with String.Empty which resolves to ""

You could also modify the table so an empty string ('') is the default for the field. Having a NULL constraint would prevent a user from overriding the default and inserting a null.
0
 

Author Comment

by:lmgregg
ID: 20314203
Where should I insert this code? I guess into DataBinding SUB? Thank you.
0
 
LVL 7

Expert Comment

by:nisarkhan
ID: 20314230
in stored procedure or in your sql statement
0
 
LVL 7

Expert Comment

by:nisarkhan
ID: 20314390
ptakja:

>>>Or, you can replace empty_string with String.Empty which resolves to ""

sql server will not understand the language of .net and its totally incorrect what you have said above.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question