2015-11-02 43 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(); 

這是如何做到這一點只是圍脖草圖...希望它有助於