The following code displays as it is in browser instead of expected output. I have the table in sql server 2008. I have this code in webmatrix.
<%@ Page Language="VB" %>
@{
var db = Database.Open("databasename"); 'database name in sql server is 'databasename'
var selectQueryString = "SELECT column_date, sum(qty1) as quantity1,
sum(qty2) as quantity2, sum(qty3) as quantity3
from tbldaily group by column_date order by column_date";
}
<!DOCTYPE html>
<html>
<body>
<h1>First table test</h1>
<table>
<tr>
<th>at_date</th>
<th>quantity1</th>
<th>quantity2</th>
<th>quantity3</th>
</tr>
@foreach(var row in db.Query(selectQueryString))
{
<tr>
<td>@row.column_date</td>
<td>@row.quantity1</td>
<td>@row.quantity2</td>
<td>@row.quantity3</td>
</tr>
}
</table>
</body>
</html>
I feel there is mistake somewhere in this code. Can you help me to fix this? Please let me know if you want more information regarding my database structure or table that may help to understand my scenario better
Looks like you are mixing Razor syntax with WebPages. Name your file *.cshtml and remove the first line which is for WebPages. The rest of your code is valid C# razor.