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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:37:31+00:00 2026-05-27T16:37:31+00:00

Im Passing a querystring to my load page (ID) and then trying to SELECT

  • 0

Im Passing a querystring to my load page (ID)
and then trying to SELECT a column of that row (Status) so its eventually only one cell.

My goal is to take some Label(not a textbox) in the page that has some text, and place it in the “Status” cell.

this is my code :

this.conn = new SqlConnection(ConnString);
conn.Open();
string idIndex = Request.QueryString[“ID”];
string sqlquery1 = “INSERT INTO Movies (Status) VALUES (@Status)”;
string sqlquery2 = “SELECT Status FROM Movies WHERE ID=” + idIndex;

        cmd = new SqlCommand(sqlquery2, conn);
        adapter = new SqlDataAdapter(sqlquery2, conn);
        dt = new DataTable();
        adapter.Fill(dt);
        string data = "";

        foreach (DataRow dataRow in dt.Rows)
        {
            data = dataRow["Status"].ToString();
        }

        if (data == "")
        {
            string username = UserNameOrGuest.Text;
            cmd = new SqlCommand(sqlquery1, conn);
            cmd.Parameters.AddWithValue("Status", username);
            ErrorLabel.Text = "Movie rental succeeded!";
            cmd.ExecuteNonQuery();

        }
        else
        {
            ErrorLabel.Text = "The movie is already rented by somebody else.";
        }
    }

And I get an exception :

” Cannot insert the value NULL into column ‘Ganere’, table ‘Movie.dbo.Movies’; column does not allow nulls. INSERT fails.
The statement has been terminated.”

(“Ganere” its another column from the table, that I dont want it to pass.)

THanks for the helpers!

  • 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-05-27T16:37:32+00:00Added an answer on May 27, 2026 at 4:37 pm

    That’s not really how a table works. When inserting a record, that record needs to meet the data integrity criteria of the table. In this particular case, it sounds like the table has a required column. (It may even have more required columns and that’s just the first one it encountered in your query.)

    Your options at this point are:

    1. Insert a value into that column as well, either a dummy/default value or something real.
    2. Alter the table to allow null in that column.
    3. Alter the table to have a default value for that column when one isn’t supplied.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have web page which is passing a querystring parameter to page 2: <a
what is the best way of passing querystring to another page, i would definitly
Currently I use: RewriteRule ^([^/\.]+)/?$ page.php?page=$1 [L] Which is good for when passing one
I have a few buttons in my script that call window.open('myUploadScript.php?arguments=test...',''). I'm passing querystring
i am passing paramters from one page to another all witht he same name...how
Looking for advice on passing variables from page to page without using QueryString. The
I have about 20 div's in an aspx page. At any time, only one
I'm passing query string parameter to .aspx page with 'Ñ' character in value. But
passing post data using cURL requires that the name of the input. However, I
I am passing an encrypted URL string: Default.aspx?S3tLlnIKKzE%3d I want to pass that URL

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.