Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 54991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:18:26+00:00 2026-05-10T17:18:26+00:00

I was previously taught today how to set parameters in a SQL query in

  • 0

I was previously taught today how to set parameters in a SQL query in .NET in this answer (click).

Using parameters with values are fine, but when I try to set a field in the database to null I’m unsuccessful. Either the method thinks I am not setting a valid parameter or not specifying a parameter.

e.g.

Dim dc As New SqlCommand('UPDATE Activities SET [Limit] = @Limit WHERE [Activity] = @Activity', cn)  If actLimit.ToLower() = 'unlimited' Then     ' It's not nulling :(     dc.Parameters.Add(New SqlParameter('Limit', Nothing)) Else     dc.Parameters.Add(New SqlParameter('Limit', ProtectAgainstXSS(actLimit))) End If 

Is there something I’m missing? Am I doing it wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T17:18:27+00:00Added an answer on May 10, 2026 at 5:18 pm

    you want DBNull.Value.

    In my shared DAL code, I use a helper method that just does:

        foreach (IDataParameter param in cmd.Parameters)     {         if (param.Value == null) param.Value = DBNull.Value;     } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Previously i was able to download YouTube videos as mp3 via youtube-mp3.org Using this
Previously I had: MyClass::MyClass() : myMember(VALUE,this,5,etc.) { ... } but I need to do
Previously for all our asp.net applications we have been using a sysadmin user within
Previously I had been using this.CommandBindings.Add( new CommandBinding(ApplicationCommands.Copy, this.cmdCopy_Executed, this.cmdCopy_CanExecute)) where cmdCopy_Executed is a
Previously .NET SQLite libraries were available from http://sqlite.phxsoftware.com , but they have recently been
Previously, this function worked for me... $this_day = Day_of_Week($lyear, $month, $day); using this lib..
Previously I was using CBR_9600 when communicating with 9600 baud devices. But there does
Previously i working on SQL Server 2005 and i used MARS functionality but currently
Previously when executing unit tests with xunit.net / testdriven.net I could see output written
Previously we had desktop applications but given the fact that accessing the server (either

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.