UFO Disko 0 Newbie Poster

Hello,

I'm currently following the video tutorials found on asp.net (the site)\
And I just finished my delete page but I'm getting errors.

This is the code of the page DeleteMovie.cshtml

@{
    Layout = "~/_SiteLayout.cshtml";
    
	var id = Request["MovieID"];
	var SQLSELECT = "SELECT * FROM Names where MovieID=@0";
	var db = Database.Open("Movies");
	var Movie = db.QuerySingle(SQLSELECT, id);
	var MovieName = Movie.MovieName;
	if(IsPost)
		{
			var SQLDELETE = "DELETE FROM Names WHERE ID=@0";
			db.Execute(SQLDELETE, id);
			Response.Redirect("Default.cshtml");
		}
}
<h1>Delete Movie</h1>
<p>Are you sure you want to delete <b>@Movie.MovieName</b>?
<form action="" method="post">
	<input type="submit" value="Yes" />
	<input type="button" value="No" onclick="window.location = 'Default.cshtml'" />
</form>

And this is the error I'm receiving

The column name is not valid. [ Node name (if any) = ,Column name = ID ]

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.SqlServerCe.SqlCeException: The column name is not valid. [ Node name (if any) = ,Column name = ID ]

Source Error: 


Line 10: 		{
Line 11: 			var SQLDELETE = "DELETE FROM Names WHERE ID=@0";
Line 12: 			db.Execute(SQLDELETE, id);
Line 13: 			Response.Redirect("Default.cshtml");
Line 14: 		}

Source File: c:\Users\utopicvision\Documents\My Web Sites\DemoSite\DeleteMovie.cshtml    Line: 12

What am I doing wrong here?
I only have 1 table and 3 fields in my database: MovieID, MovieName, MovieGenre

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.