开发者

How do I run a Dynamic SQL Query in Webmatrix?

I'm working on something in WebMatrix that runs an SQL Query. I can do that, however, it Selects * From UserProfile WHERE Email = @WebSecurity.CurrentUserName. I have no idea how to get it to read only a column where Email = @WebSecurity.CurrentU开发者_如何学编程serName. I listed my code below.

@{
var db=Database.Open("AeroSC");
var sqlQ = "SELECT * FROM UserProfile";
var data = db.Query(sqlQ);
}

How do I go about doing this?

Thanks!


@{
    var db = Database.Open("AeroSC");
    var sqlQ = "SELECT Id FROM UserProfile WHERE Email = @0";
    var id = db.QueryValue(sqlQ, WebSecurity.CurrentUserName);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜