...

View Full Version : CSHTML and SQL



daza93
11-27-2011, 12:28 PM
Can someone help me with this - using CSHTML and getting info from a db. I have the following



@{
var id = Request["movieID"];
var db = Database.Open("db");
var selectQueryString =
"SELECT * FROM Showings, Cinemas WHERE showings.movieID=@0 AND showings.cinemaID = Cinemas.cinemaID";
var result = db.Query(selectQueryString,id).FirstOrDefault();
}



<!DOCTYPE html>

<html lang="en">
<head>
<title>GCUScreens Showings Detail</title>
<link rel="stylesheet" type="text/css" href="theme.css" />
</head>
<body>
<img src="Untitled.jpg" width="750" height="650"/>
<h1>GCUScreens Showings Detail</h1>
<p>Date: @string.Format("{0:d}",result.showingdate)</p>
<p>Time: @result.showingtime</p>
<p>Screen: @result.screen</p>
<p>Town: @result.town</p>
<p>Address: @result.address</p>
</body>
</html>


which gets the MovieId from another page and displays any showings for that movie and it does this fine unless no showings exist for the movie then it just shows an error.

So can someone tell me how to check if the movieID exists in showings and if it does do the above otherwise display "No Showings for this movie"?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum