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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:34:48+00:00 2026-06-06T15:34:48+00:00

With my Application, i want to make sure if user enter no value in

  • 0

With my Application, i want to make sure if user enter no value in a textbox, and click on the
save button to send data in the sqlserver db.The database side validation prevent this violation and set ErrorMessage which my application will catch and Display a meaninful Message
to the User. For each required field i set it to NOT NULL. But when i test,i can still enter
enter empty textbox values it gets inserted with out value.
what am i missing?

string connectionstring = "Data Source=abcdef;Initial Catalog=HMS;Persist Security Info=True;User ID=sysad;Password=abcdef";
        SqlConnection connection = new SqlConnection(connectionstring);

        string SelectStatement = "SELECT * FROM tablename where RegistrationNo = @RegistrationNo";
        SqlCommand insertcommand = new SqlCommand(SelectStatement, connection);
        insertcommand.Parameters.AddWithValue("@RegistrationNo", textBox10.Text);
        SqlDataReader reader;
        try
        {
            connection.Open();
            reader = insertcommand.ExecuteReader();

            while (reader.Read())
            {
                textBox11.Text = reader["RegistrationNo"].ToString();
                textBox1.Text = reader["Appearance"].ToString();
                textBox2.Text = reader["VolumePH"].ToString();
                textBox3.Text = reader["Mobility"].ToString();
                textBox4.Text = reader["Viability"].ToString();
                textBox5.Text = reader["Head"].ToString();
                textBox6.Text = reader["MiddlePiece"].ToString();
                textBox7.Text = reader["Tail"].ToString();
                textBox8.Text = reader["SpermCount"].ToString();
                dateTimePicker1.Text = reader["Date"].ToString();
                textBox9.Text = reader["Comment"].ToString();



            }//end while
            reader.Close();
        }
        catch (Exception ex)
        {
            throw ex;

        }//end catch
  • 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-06T15:34:50+00:00Added an answer on June 6, 2026 at 3:34 pm

    What am i missing?

    I think you are missing a distinction between null and an empty string.

    Databases distinguish between null and empty. If your ToString succeeds, then you have a non-null string there, and so DB is happy to accept it as a valid value.

    In general, using DB for user-side validation is somewhat wasteful: if you know that the field must not be empty, you should check for it in the UI; DB validation should serve as the last resort that preserves the integrity of your data model.

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

Sidebar

Related Questions

I'm working on an html5 application built on CouchDB. I want to make sure
I want make interactive application where user launches it and can do various task
My C++ application stores some common user data in %CSIDL_COMMON_APPDATA%\Company\Product . I want to
I my application i want to make the text seleected selected using mouse bold..How
We have an application that we want to make available to the general internet-using
I'm creating a very simple django upload application but I want to make it
I want to make an Application that uses RxTx version 2.2pre2 to work with
I want to make an application witch involves logging into google. It is basically
I want to make an console application of c which can run other applications
I want to make an application in C or C++ which have to monitor

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.