2015-11-02 67 views
0

我正在使用WebMatrix在我的用户数据库中创建表。Web Matrix,数据类型,用户注册

我的tutorial表示使用BOOLEAN数据类型来确定用户注册是否处于活动状态,因为它允许该字段为true或false。 BOOLEAN不是一种选择。

我可以用什么来取得同样的效果?

请随时要求澄清。任何帮助深表感谢。即使对于创建用户注册/成员系统的其他教程建议也会很好。谢谢!

+0

允许哪些数据字段?使用0 = False的整数,1 = True肯定会起作用。 – jaynp

回答

0

您正在查找的答案是“位”,默认值为0(零),这将被MS SQL Server 2012解释为false。要说另一种方式,Webmatrix中的“bool”值等于“位”的值在MS SQL Server 2012的

// on the webmatrix side of things 
Int UserID = 0; // the users id (usually int) 
bool allowed = false; 

// the database needs at least 2 fields 

int UserID; 
bit Allowed; 


var db = Database.Open("TheDatabase"); 
// don't forget to set this up in your web.config file. 
var TestRecord = db.QuerySingle("SELECT * FROM webpages_Membership WHERE [email protected]", UserID); 

allowed TestRecord.Allowed; 

db.close(); 

这是如何做到这一点只是围脖草图...希望它有助于