Solved

How to set Oracle date to null with ODBC?

Posted on 2002-07-05
4
1,488 Views
Last Modified: 2008-03-17
Does anyone know how to set an Oracle date field to null using ODBC?  

My code statement is the following:
rs.Fields("BillingDate") = IIf(IsNull(Me.txtBillingDate), Null, Trim(Me.txtBillingDate))

I get an error everytime it gets executed.  The Errors collection returns that there was a data type mismatch.   I have read articles that say that you can't assign an Oracle date the null value using ODBC.  However, I have some older code examples where I was able to do this.  Not sure why it isn't working now.  

I don't want to have to use SQLPassThrough queries (Insert, Update statements) because of the time involved.

Any ideas?
Thanks.
0
Comment
Question by:mnord
4 Comments
 

Author Comment

by:mnord
ID: 7132284
I am using VB6 with DAO and Oracle 8i.
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 100 total points
ID: 7133250
Try this:
rs.Fields("BillingDate") = IIf(Len(Trim$(Me.txtBillingDate)) = 0 , Null, Trim(Me.txtBillingDate))

Or better still (easier to read):

Dim sBillingDate As String

SBillingDate = Trim$(Me.txtBillingDate)
If Len(sBillingDate) Then
   rs.Fields("BillingDate").Value = sBillingDate
Else
   rs.Fields("BillingDate").Value = Null
End if

Anthony
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7990736
Hi mnord,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept acperkins@devx's comment(s) as an answer.

mnord, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:SpideyMod
ID: 8053108
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

758 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now