[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

MS Access - how to convert null values to empty string in select statement ?

Posted on 2007-10-10
11
Medium Priority
?
14,145 Views
Last Modified: 2008-05-21
I've used this method in sql to convert null value to empty string but I'm looking for a hand in how to do the same with MS Access select query:

sql syntax:

select IsNull(Terms,'') As Terms from Customer

Access syntax ??


Thanks,
JMO9966
0
Comment
Question by:JMO9966
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 20053864
select Nz(Terms, "") As Terms from Customer
0
 

Author Comment

by:JMO9966
ID: 20053924
Thanks, your syntax is good and now I'm remembering I've struggled with this in the past also.

The query runs fine in Microsoft Access but I can't get this query to run from my vb.net app that is using an Odbc.OdbcConnection.

I get an error about an unrecognized function ??

Any thoughts would be appreciated.
0
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 600 total points
ID: 20053930
Sorry, not a .net guy :)
0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 

Author Comment

by:JMO9966
ID: 20053965
Is there a way to cast this to varchar in Access query and work around this ?

Thanks
0
 
LVL 6

Assisted Solution

by:cottsak
cottsak earned 400 total points
ID: 20053973
Nz() only works within Access and is not valid thru Odbc.OdbcConnection. try IsNull() again or perhaps handle the null values in VB.NET after you have your recordset/dataset returned from the query.
0
 

Author Comment

by:JMO9966
ID: 20054165
Ya, I know I've worked around this before.

I thought about doing this in code, but my select query blows up even with simple select because some records have a null value for this field.

I need to use an ODBC connection to use an existing DSN database pointer.

Thanks though
0
 

Author Comment

by:JMO9966
ID: 20054169
IsNull errors out too on this Access database.  
0
 
LVL 6

Expert Comment

by:cottsak
ID: 20054174
what is the error in .NET using ODBC?
0
 

Author Comment

by:JMO9966
ID: 20054216
straight select statement = "Conversion from type DBNull to String is not valid"

select with nz and isnull attempts = "unrecognized command or wrong number of arguments"  

I ended up creating a datatable and filling this with selectCommand versus a odbc command with ExecuteScalar and now the datatable gets filled with null values where they exist and then I convert these to empty strings in the datatable before gathering value.

Thanks guys
0
 
LVL 6

Expert Comment

by:cottsak
ID: 20054253
no problems. thanx for the points and grade.
happy coding.
0
 

Expert Comment

by:LouieGee
ID: 20420233
I know this question is closed but I usually use this:
select Terms & "" As TermsFixed from Customer
This usually handles it for me, and I haven't had any problems, but I don't know what the rest of you think about it.
Also, I don't know if it will work with ODBC or .NET.
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

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

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

834 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