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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:50:34+00:00 2026-06-17T12:50:34+00:00

I have faced a problem with the dataset when inserting record into DB.I have

  • 0

I have faced a problem with the dataset when inserting record into DB.I have a table address in which phno (AllowNulls=False,Defaultvalue=’0′) and mbno(AllowNulls=True,Defaultvalue=’0′) .While inserting record into database through dataset when I didn’t supply any input to the both columns phno is taking default value(‘0’) and mbno is taking “Null”.I suppose both has to take default value when there is no input.

I dont know why this is happening.I have written code like this

    SqlConnection con = new SqlConnection(connStr);
    DataSet ds = new DataSet();
    DataRow dr;
    SqlCommand cmd = new SqlCommand("select * from address",con);
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    SqlCommandBuilder cmdBuilder;
    da.FillSchema (ds,SchemaType.Source );
    da.Fill(ds, "address");

    dr = ds.Tables["address"].NewRow();
    dr["sname"] = "tomy";
    dr["fname"] = "peter";

    ds.Tables["address"].Rows.Add(dr);

    cmdBuilder = new SqlCommandBuilder(da);
    da.Update(ds, "address");
  • 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-17T12:50:36+00:00Added an answer on June 17, 2026 at 12:50 pm

    In the remarks-section of this msdn reference page it is explained, what value will be inserted in which cases.
    Since AllowNulls = true on your DataSet it probably submits a null to the database, which will let the database insert a null.
    If you want to have your default value inserted, remove AllowNulls or explicitly remove the parameter from the insert statement (you would have to write your own InsertCommand in this case).

    Btw, what do you want archieve by the combination of AllowNull and Default?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I faced an interesting problem today. I have 4 strings which I need to
we have faced a problem with our production system yesterday which I am unable
I have faced a problem in Qt with error: cannot convert parameter 1 from
I have faced the same problem many times. The Same Problem was With This
I have a problem that I have not faced before: It seems that the
We've faced strange problem. We have log on service, that authenticates user, adds auth
Today I faced a strange problem in C#. I have an ASP.NET page where
I have designed a custom section handler before but I'm faced with a problem
i have faced this problem couple of days ago, while trying to import an
am building an iphone app and I have faced a problem when I use

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.