Hi
This is my first attempt at trying to insert a row into a table using this code but get the compilation error below if anyone can help me please. The code is :-
@{
var db = Database.Open(“MatrixMan”);
var titleEntry = Response[“title”];
var notesEntry = Response[“notes”];
var imageEntry = Response[“image”];
if (IsPost){
var insertQ = "INSERT INTO Journal (DateCreate, DateEdit, Title, Notes, Image) VALUES (@1,@2,@3,@4,@5)";
db.Execute(insertQ,
DateTime.Now.ToLongDateString, DateTime.Now.ToLongDateString, titleEntry, notesEntry, imageEntry);
Response.Redirect(@Href("~/index.html"));
}
}
<!DOCTYPE html>
<html lang=“en”>
<head>
<meta charset=“utf-8” />
<title>The Matrix Man</title>
<link href=“StyleSheet1.css” rel=“stylesheet” type=“text/css” />
</head>
<body>
<div id=“header”>
</div> <!-- end of header div –>
<div id="bodycontent">
<form action="" method="post">
Title <input type="text" name="title" tabindex="1" value="@title"></input>
<br />
Notes <input type="text" name="notes" tabindex="1" value="@notes"></input>
<br />
Image <input type="text" name="image" tabindex="3" value="@image"></input>
<br />
<input type="submit" value="Insert" name="Submit"></input>
</form>
</div> <!-- end of bodycontent div -->
</body>
</html>I get this error. I followed another book which implied that I use the value keyword but this made no difference. I still get the same error :-
Server Error in ‘/’ Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0021: Cannot apply indexing with to an expression of type ‘System.Web.HttpResponseBase’
Source Error:
Line 1: @{
Line 2: var db = Database.Open(“MatrixMan”);
Line 3: var titleEntry = Response[“title”];
Line 4: var notesEntry = Response[“notes”];
Line 5: var imageEntry = Response[“image”];
Source File: c:\Users\CATSPC5\Documents\My Web Sites\MatrixMan\inputjournalentry.cshtml Line: 3
Much appreciated if someone could help me on my way please.
Kind Regards
Matt
p.s even if I delete line 3, then I just get the same error affecting line 4