Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How to get search results to display all if no records found? Hi there, I am working with an sql database using asp and I

How to get search results to display all if no records found?

Hi there, I am working with an sql database using asp and I am doing a movie database. I want my table to display all record if no searches were found for a movie but am unsure how to do that.

image text in transcribed

When I do search for a movie that is in a record it displays the result, but when it isn't I only get "Movie Not Found" as in the response.write.

/I search function for movies when user has logged in protected void Search_func (Object src, EventArgs e) get_connection(); connection.Open); //string root Server.MapPath(" //string path root "C:\Users Jak Desktop Test3 Milestone2 Milestone2\Upload\2fast2furious.jpg" //string FileName = path + MovieResults.SelectedItem; commandnew SqlCommand ("SELECT FROM content WHERE MovieTitle-@MovieTitle", connection); command.Parameters.AddwithValue("@MovieTitle", MovieTitle.Text); //command.Parameters.AddlithValue("@ImageLocation", path); readercommand.ExecuteReader(); if (reader.HasRows) MovieResults.Visibletrue; else Response.Write("Movie Not Found"); commandnew SqlCommand ("SELECT FROM content, connection); MovieResults.Visible -true; MovieResults . DataSource reader; MovieResults.DataBind); reader.Close)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

3rd Edition

0128012757, 978-0128012758

More Books

Students also viewed these Databases questions