Esempio n. 1
0
        public int Update()
        {
            int result = 0;

            if (User.Current != null)
            {
                bool check = CheckExists(Name);

                if (!check)
                {
                    result = -1;
                }
                else
                {
                    Security security = new Security();
                    XmlDocument connections = security.ReadConnectionConfiguration(User.Current.Path);

                    XmlNode node = connections.SelectSingleNode("/root/connections/connection[name='" + Name + "']");
                    if (node != null)
                    {
                        node.SelectSingleNode("name").InnerText = Name;
                        node.SelectSingleNode("server").InnerText = Server;
                        node.SelectSingleNode("dbname").InnerText = Database;
                        node.SelectSingleNode("dbuser").InnerText = Username;
                        node.SelectSingleNode("dbpass").InnerText = Password;
                        node.SelectSingleNode("provider").InnerText = Provider;

                        security.SaveConnection(User.Current.Path, connections);

                        result = 1;
                    }
                    else
                    {
                        result = -3;
                    }
                }
            }
            else
            {
                result = -2;
            }

            return result;
        }