SQLserver 2005应该调用什么存储过程才可以在新建用户时不让“强制实施密码策略”打上勾?
public bool AddUser(string cUserName,string Password,string DB) { System.Data.SqlClient.SqlConnection oCon=new System.Data.SqlClient.SqlConnection("data source=.;initial catalog=master;password=123456;persist security info=True;user id=sa"); try { oCon.Open(); } catch { return false; } System.Data.SqlClient.SqlCommand oAddUser=new System.Data.SqlClient.SqlCommand(); oAddUser.CommandType=System.Data.CommandType.Text; oAddUser.Connection=oCon; oAddUser.CommandText="exec sp_addlogin '"+cUserName+"','"+Password+"','"+DB+"'"; int i=oAddUser.ExecuteNonQuery(); if(i==0) { return false; } else { return true; } } private void button1_Click(object sender, EventArgs e) { AddUser("abcde","1234","master"); }
CREATE LOGIN [BaseUser] WITH PASSWord=N'baseuser',DEFAULT_DATABASE=[TRS],CHECK_EXPIRATION=OFF, CHECK_POLICY=OFFGO
[解决办法]