Solved

Write null to SQL Server from Access with ADO

Posted on 2012-03-29
5
404 Views
Last Modified: 2012-03-30
I'm trying to write Null to a column in a SQL Server table that is set to take nulls.

I'm using ADO to do this in conjunction with stored procedure parameters.

I've tried setting the parameter value to VBNull and DBNull but VBNull loads 1 to the table and DBNull loads 0.

Is there a way for me to load nulls with ADO?

Thanks.
0
Comment
Question by:lee_jd
  • 3
  • 2
5 Comments
 
LVL 10

Accepted Solution

by:
plummet earned 500 total points
ID: 37783624
Hi Lee_JD

If you want to pass a null value simply don't set the parameter value at all - leave it out - or you could also set it to Empty.

Hope that helps!
John
0
 
LVL 2

Author Comment

by:lee_jd
ID: 37786188
I need to overwrite the value in the database with Null so not setting a value is not an option.  Also setting the value to Nothing doesn't work either.
0
 
LVL 10

Expert Comment

by:plummet
ID: 37786329
What are you writing this in? Are you using .net, c#, vb, ASP, vb6, VBA?
0
 
LVL 2

Author Comment

by:lee_jd
ID: 37786341
It's okay.  I sorted it with

If value 0 then parameter.value = null else parameter.value = type.value
0
 
LVL 10

Expert Comment

by:plummet
ID: 37786406
Great, well done

Cheers
John
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

831 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