2014-08-30 52 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