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);
}
精彩评论