2014-08-30 90 views
0

我一直在尝试创建一个查询来查询数据库并将其复制,以便您可以管理该网站的所有用户。尺寸错误剃刀语法

由于某些原因,For Each给出了Dim的预期表达式的错误。

任何帮助理解错误将不胜感激。

@Code 
PageData("Title") = "Admin" 
Layout = "~/_SiteLayout.vbhtml" 

Dim db As Database = Database.Open("StarterSite") 
Dim selectQueryString = ("SELECT * From UserProfile BY email") 





End Code 

<section> 
Hello and welcome to the control section of the website: 

Below is the table of all of the users... Hopefully 

<table> 
    <tr> 
     <th>Username</th> 
     <th>Password</th> 
     <th>email confirmation</th> 
    </tr> 



    @For Each(Dim row in db.Query(selectQueryString)){ 

    <tr> 
     <td> @row.email </td> 
     <td> @row.password </td> 
     <td> @row.requireEmailConfirmation </td> 
    </tr>; 
    } 
    Next completed 
</table> 

回答

0

您需要从For Each语句删除Dim,大括号,括号和分号。他们属于C#而不是VB。

@For Each row in db.Query(selectQueryString) 
    @<tr> 
     <td> @row.email </td> 
     <td> @row.password </td> 
     <td> @row.requireEmailConfirmation </td> 
    </tr> 
Next 

而且,你不需要括号周围的selectQueryString变量:

Dim selectQueryString = "SELECT * From UserProfile BY email" 

如果你想使用VB作为你的语言,你应该花一些时间来学习它的语法和它是如何工作与剃刀。这是一个很好的起点:http://www.asp.net/web-pages/tutorials/basics/asp-net-web-pages-visual-basic