C J
C J

Reputation: 417

Saving data in table in SQL Server 2005

I am asp.net developer and I work with SQL Server 2005 .

I have a table with 4 columns

say

  1. Name
  2. RollNo
  3. Std
  4. Div

if client enters

  1. Name
  2. RollNo
  3. Std

but doesn't enters 4.Div column data and try's to save data, it should not give error, it should save the data in database

Upvotes: 0

Views: 564

Answers (3)

Manish Pansiniya
Manish Pansiniya

Reputation: 545

HI,

That means that you need to save with either default division for standard or null value.

You can setup in database to allow null and do not pass anything and that saves the data with null values.

Otherwise, I think you should put default value in Div for that standard. So whenever you dont pass that value in Insert statement, it takes default one.

Will it help or do I misunderstood it?

Upvotes: 0

Eaglebird
Eaglebird

Reputation: 532

If I understand your problem, you're going to have NULL in one of your fields (provided you allow nulls in the fields). Depending on where you're experiencing your problem, your code would need to test for NULL from the information a client inputs or your code will need to test for NULL when it retrieves the information.

If you're running into an error, it might be prudent to post details of the error as well.

Upvotes: 0

The Muffin Man
The Muffin Man

Reputation: 20004

So it is giving you an error? Make sure that you set 4. Div column to "Allow Nulls"(No value).

It's also good to know that SQL Server can be set up to insert a default value if one isn't provided.

Upvotes: 1

Related Questions