示例#1
0
        protected void GridViewColumns_PageIndexChanged(object sender, EventArgs e)
        {
            ConnInfo connInfo = ConnInfo.getConnInfo(conID);

            string connectionString = "";
            string providerName     = "";

            //Set drop down box accordingly
            if (connInfo.getDatabaseType() == ConnInfo.MSSQL)
            {
                connectionString        = "Data Source=" + connInfo.getServerAddress() + ";Initial Catalog=" + connInfo.getDatabaseName() + ";Persist Security Info=True;User Id=" + connInfo.getUserName() + ";Password="******"SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE (TABLE_NAME = '" + selectedGVTable.Value + "')";
                ColGen.DataBind();
            }

            else if (connInfo.getDatabaseType() == ConnInfo.MYSQL)
            {
                connectionString        = "server=" + connInfo.getServerAddress() + ";User Id=" + connInfo.getUserName() + ";password="******";Persist Security Info=True;database=" + connInfo.getDatabaseName();
                providerName            = "MySql.Data.MySqlClient";
                ColGen.ConnectionString = connectionString;
                ColGen.ProviderName     = providerName;
                ColGen.SelectCommand    = "SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE (TABLE_NAME = '" + selectedGVTable.Value + "')";
                ColGen.DataBind();
            }

            else if (connInfo.getDatabaseType() == ConnInfo.ORACLE)
            {
                connectionString        = "Data Source=" + connInfo.getServerAddress() + ";Persist Security Info=True;User ID=" + connInfo.getUserName() + ";Password="******";Unicode=True";
                providerName            = "System.Data.OracleClient";
                ColGen.ConnectionString = connectionString;
                ColGen.ProviderName     = providerName;
                ColGen.SelectCommand    = "SELECT COLUMN_NAME FROM dba_tab_columns WHERE (OWNER IS NOT NULL AND TABLE_NAME = '" + selectedGVTable.Value + "')";
                ColGen.DataBind();
            }

            else //Default set to SQL
            {
            }

            //Garbage collection
            connInfo = null;
        }
示例#2
0
        protected void GridViewTables_SelectedIndexChanged(object sender, EventArgs e)
        {
            columnButtons.Visible = true;
            columnMessage.Visible = false;
            string selectedTable = GridViewTables.SelectedValue.ToString();

            selectedGVTable.Value = selectedTable;

            string pageInfo = "viewTable.aspx?con=" + conID + "&tbl=" + selectedTable;
            string window   = "window.open('" + pageInfo + "'); return false;";

            viewTable.Attributes.Add("onclick", window);

            if (selectedTable != "")
            {
                ConnInfo connInfo = ConnInfo.getConnInfo(conID);

                string connectionString = "";
                string providerName     = "";

                //Set drop down box accordingly
                if (connInfo.getDatabaseType() == ConnInfo.MSSQL)
                {
                    connectionString        = "Data Source=" + connInfo.getServerAddress() + ";Initial Catalog=" + connInfo.getDatabaseName() + ";Persist Security Info=True;User Id=" + connInfo.getUserName() + ";Password="******"SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE (TABLE_NAME = '" + selectedGVTable.Value + "')";
                    ColGen.DataBind();
                }

                else if (connInfo.getDatabaseType() == ConnInfo.MYSQL)
                {
                    connectionString = "server=" + connInfo.getServerAddress() + ";User Id=" + connInfo.getUserName() + ";password="******";Persist Security Info=True;database=" + connInfo.getDatabaseName();
                    providerName     = "MySql.Data.MySqlClient";

                    ColGen.ConnectionString = connectionString;
                    ColGen.ProviderName     = providerName;
                    ColGen.SelectCommand    = "SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE (TABLE_NAME = '" + selectedGVTable.Value + "')";
                    ColGen.DataBind();
                }

                else if (connInfo.getDatabaseType() == ConnInfo.ORACLE)
                {
                    connectionString = "Data Source=" + connInfo.getServerAddress() + ";Persist Security Info=True;User ID=" + connInfo.getUserName() + ";Password="******";Unicode=True";
                    providerName     = "System.Data.OracleClient";

                    ColGen.ConnectionString = connectionString;
                    ColGen.ProviderName     = providerName;
                    ColGen.SelectCommand    = "SELECT COLUMN_NAME FROM dba_tab_columns WHERE (OWNER IS NOT NULL AND TABLE_NAME = '" + selectedGVTable.Value + "')";
                    ColGen.DataBind();
                }

                else //Default set to SQL
                {
                }


                Mapping conMapping = Mapping.getMapping(conID, selectedTable);

                string dbTable = conMapping.getTableName();

                int dbFormat = conMapping.getFormat();

                string dbLat  = conMapping.getLatFieldName();
                string dbLong = conMapping.getLongFieldName();

                //No information about the table yet
                if (dbTable == null)
                {
                    mapUpdates(ColGen);
                }

                else
                {
                    mapUpdates(ColGen, dbLat, dbLong, dbFormat);
                }

                //Garbage collection
                connInfo = null;
            }
            else
            {
                iColFNBox.Items.Clear();
                UpdateFieldCol.Update();
            }
        }