日期:2014-05-18 浏览次数:20381 次
public void addUser(User user) { string sql = "insert into Users(UserName, UserPwd) values(@name, @password)"; SqlCommand command = Database.GetInstance().GetCommand(connection, sql); command.Parameters.Add("@name", SqlDbType.VarChar); command.Parameters.Add("@password", SqlDbType.VarChar); command.Parameters[0].Value = user.Username; command.Parameters[1].Value = user.Password; try { command.ExecuteNonQuery(); } catch (System.Exception ex) { throw ex; } finally { Database.GetInstance().Close(command); } }