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 7845623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:17:42+00:00 2026-06-02T17:17:42+00:00

I have a web from that has a few text boxes which are visible

  • 0

I have a web from that has a few text boxes which are visible only under certain conditions. These textboxes are bound to calender extenders.However whenever not visible these pass null string to the database. Their corresponding datatype in the table is datetime. While storing these null strings they are converted to 1/1/1900 12:00:00 AM. How can i have a null value stored here instead ?

Do i need to change the data type to some thing else ??

I’m using datetime because i need to perform some comparison operations later.

Relevant code is here.

public class Asset
{ 

public string dbStatus { get; set; }
public string wtyEndDate { get; set; }
public string amcEndDate { get; set; }


 public Asset()
 {
    dbStatus = default(String);
    wtyEndDate = default(String);
    amcEndDate = default(String);
 }
}

 protected void btnSaveAsset_Click(object sender, EventArgs e)
  { 
    Asset a = new Asset();
    a.wtyEndDate = txtWtyEndDate.Text;
    a.amcEndDate = txtAmcEndDate.Text;
    string msg = "";
    if (a.dbStatus == "INSERT")
    {
      try
       {
           msg = (ab.EXE_Assets_Master(a).Rows.Count>0) ? "Record Inserted"; : "Error"
        }
        catch (Exception)
        {
            msg = "Record with this service tag already exists in the database";
        }
    }
 }

 protected DataTable _EXE_Asset_Details(Asset a)
  {
    Parameters.Clear();

    AddParameter("@wtyEndDate", a.wtyEndDate);
    AddParameter("@amcEndDate",a.amcEndDate);
    AddParameter("@DBStatus", a.dbStatus);

    return ExecuteDataSet("[Asset_Details]").Tables[0];
    }

// Asset_Details

CREATE PROCEDURE [Asset_Details]
@wtyEndDate datetime = NULL, 
@amcEndDate datetime =null, 
@dbStatus nvarchar(50)

AS
IF(@DBStatus='INSERT')
BEGIN
 INSERT INTO [assetsMaster]
       ([warrantyEndDate],[amcEndDate])
  VALUES
       ( @wtyEndDate,@amcEndDate)
  SELECT @@rowcount

END
  • 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. Editorial Team
    Editorial Team
    2026-06-02T17:17:45+00:00Added an answer on June 2, 2026 at 5:17 pm

    Only add the optional DateTime parameters if they have data in them.

    For example:

    if(!string.IsNullOrWhiteSpace(a.wtyEndDate))
    {
        AddParameter("@wtyEndDate", a.wtyEndDate);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web page that has a few text boxes, and a dual
I have a web application from a company that has gone out of business.
I have a web application that has a page that loads the content from
I have a .NET web-service client that has been autogenerated from a wsdl-file using
We have a web application that gets its data from a certain database. The
I have a asp.net web content from that have a asp.net textbox and I
I have a WCF web-service and a Silverlight app displaying data from that service.
Problem: We have a web app that calls some web services asynchronously (from the
I have a web service that queries data from this json file, but I
We have one web application (sharepoint) that collects information from disparate sources. We would

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.