IEnumerable <DevExpress.DataAccess.Sql.SqlDataConnection> IConnectionStorageService.GetConnections()
        {
            if (!File.Exists(FileName))
            {
                try
                {
                    //Create empty XML file
                    XmlDocument doc  = new XmlDocument();
                    XmlElement  root = doc.CreateElement(xmlRootName);
                    doc.AppendChild(root);
                    doc.Save(FileName);

                    //Add a connection to the XML file:

                    SqlDataConnection defaultConnection = GetConnection(); //GetConnectionsFromXml(); // new CustomSqlDataConnection("Default Connection", new MsSqlConnectionParameters("localhost", "NORTHWIND", "sa", "dx", MsSqlAuthorizationType.SqlServer));
                    SaveConnection(defaultConnection.Name, defaultConnection, true);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format("Cannot create '{0}' file because of exception:{1}{1}{2}", FileName,
                                                  Environment.NewLine, ex.Message));
                    return(null);
                }
            }

            return(IncludeApplicationConnections ?
                   DefaultStorage.GetConnections().Union(GetConnectionsFromXml()) :
                   GetConnectionsFromXml());
        }
Ejemplo n.º 2
0
    IEnumerable <SqlDataConnection> IConnectionStorageService.GetConnections()
    {
        if (!File.Exists(FileName))
        {
            try
            {
                XmlDocument doc  = new XmlDocument();
                XmlElement  root = doc.CreateElement(xmlRootName);
                doc.AppendChild(root);
                doc.Save(FileName);

                SqlDataConnection defaultConnection = new CustomSqlDataConnection("Default Connection",
                                                                                  new MsSqlConnectionParameters("localhost", "Northwind", null, null, MsSqlAuthorizationType.Windows));
                SaveConnection(defaultConnection.Name, defaultConnection, true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Cannot create '{0}' file because of exception:{1}{1}{2}", FileName,
                                              Environment.NewLine, ex.Message));
                return(null);
            }
        }

        return(IncludeApplicationConnections ?
               DefaultStorage.GetConnections().Union(GetConnectionsFromXml()) :
               GetConnectionsFromXml());
    }