コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: nusohi/TREE
        public MainWindow()
        {
            InitializeComponent();
            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;

            // 数据库连接建立
            string s = "Server =.; Database = {0}; integrated security = SSPI";

            ConnectString = String.Format(s, DatabaseName);
            textNodeDB    = new TextNodeDB(ConnectString);
            treeDB        = new TreeDB(ConnectString);

            // 数据库初始化(创建数据库/表)
            InitDB initDB = new InitDB("Server=.;Database=master;integrated security=SSPI");

            initDB.DatabaseName = DatabaseName;
            try {
                initDB.Init();
            }
            catch (Exception e) {
                MessageBox.Show(e.Message);
            }

            treeView.UpdateTreeToDB += SaveTree;
            this.Loaded             += OpenOrCreateTreeWindow;
        }
コード例 #2
0
	// in the constructor we'll define the connectionstring, table name, and column names/types
	public cs_TreeEvents()
	{
		oTreeDB = new TreeDB();

		// declaring the connection string:
		// Sql Express
        oTreeDB.ConnectionString = "Server=.\\SQLEXPRESS;AttachDBFilename=|DataDirectory|TreeNodes.mdf;Database=TreeNodes;Trusted_Connection=Yes;";
		
        //MSSQL Server
		//oTreeDB.ConnectionString = "Driver={SQL Server};Server=localhost;UID=obout_usr;PWD=obout_pwd;Database=obout;";

		//MySql
		//oTreeDB.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};Server=localhost;UID=root;PWD=root_pwd;Database=test";
		
		

		// declaring the table name:			
        oTreeDB.TableName = "treeview";
        oTreeDB.ProviderName = "System.Data.SqlClient";

		// declaring the name and the type of the fields from the database
        oTreeDB.Fields[TreeDB.StandardFields.ID].DbFieldName = "NodeID";
        oTreeDB.Fields[TreeDB.StandardFields.ParentID].DbFieldName = "ParentID";
        oTreeDB.Fields[TreeDB.StandardFields.HTMLValue].DbFieldName = "NodeHTML";
        oTreeDB.Fields[TreeDB.StandardFields.Icon].DbFieldName = "NodeIcon";
        oTreeDB.Fields[TreeDB.StandardFields.Level].SetProperties("NodeLevel", "numeric");
        oTreeDB.Fields[TreeDB.StandardFields.Expanded].SetProperties("Expanded", "numeric");
        
	}
コード例 #3
0
    // in the constructor we'll define the connectionstring, table name, and column names/types
    public cs_TreeEvents()
    {
        oTreeDB = new TreeDB();

        // declaring the connection string:
        // Sql Express
        oTreeDB.ConnectionString = "Server=.\\SQLEXPRESS;AttachDBFilename=|DataDirectory|TreeNodes.mdf;Database=TreeNodes;Trusted_Connection=Yes;";

        //MSSQL Server
        //oTreeDB.ConnectionString = "Driver={SQL Server};Server=localhost;UID=obout_usr;PWD=obout_pwd;Database=obout;";

        //MySql
        //oTreeDB.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};Server=localhost;UID=root;PWD=root_pwd;Database=test";



        // declaring the table name:
        oTreeDB.TableName    = "treeview";
        oTreeDB.ProviderName = "System.Data.SqlClient";

        // declaring the name and the type of the fields from the database
        oTreeDB.Fields[TreeDB.StandardFields.ID].DbFieldName        = "NodeID";
        oTreeDB.Fields[TreeDB.StandardFields.ParentID].DbFieldName  = "ParentID";
        oTreeDB.Fields[TreeDB.StandardFields.HTMLValue].DbFieldName = "NodeHTML";
        oTreeDB.Fields[TreeDB.StandardFields.Icon].DbFieldName      = "NodeIcon";
        oTreeDB.Fields[TreeDB.StandardFields.Level].SetProperties("NodeLevel", "numeric");
        oTreeDB.Fields[TreeDB.StandardFields.Expanded].SetProperties("Expanded", "numeric");
    }