/// <summary>
        /// Reads tables list. This method requires views list to prevent confliction!
        /// </summary>
        private StringCollection ReadTablesList(StringCollection viewsList)
        {
            StringCollection result = new StringCollection();

            if (_dbConnection.State != ConnectionState.Open)
            {
                _dbConnection.Open();
            }
            try
            {
                using (DataTable views = _dbConnection.GetSchema("TABLES"))
                {
                    foreach (DataRow row in views.Rows)
                    {
                        string tableName = row["TABLE_NAME"].ToString();

                        // is this view?
                        if (viewsList.Contains(tableName))
                        {
                            continue;
                        }

                        // add to results
                        result.Add(tableName);
                    }
                }
            }
            finally
            {
                _dbConnection.Close();
            }
            return(result);
        }
        private void SQLCESchema_Click(object sender, EventArgs e)
        {
            try
            {
                using (var conn = new SqlCeConnection(txtSqlCeConn.Text))
                {
                    conn.Open();
                    //string[] restriction = new string[] { txtOrclOwner.Text };

                    DataTable schema;
                    if (txtSqlCeSchemaName.Text.Length > 0)
                    {
                        schema = conn.GetSchema(txtSqlCeSchemaName.Text);                        //, restriction);
                    }
                    else
                    {
                        schema = conn.GetSchema();
                    }

                    grdGrid.DataSource    = schema;
                    grdColumns.DataSource = GetColumns(schema.Columns);
                }
            }
            catch
            {
                throw;
            }
        }
예제 #3
0
        public static DataTable Get_Table_Names()
        {
            SqlCeConnection cn = new SqlCeConnection(_connstring);
            DataTable       dt = new DataTable();

            try
            {
                cn.Open();
                dt = cn.GetSchema("Tables");
            }
            catch (SqlCeException sqlex)
            {
                MessageBox.Show(sqlex.Message, "fail");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                cn.Close();
            }

            return(dt);
        }
        private static IList <string> GetTableNames(SqlCeConnection testConn)
        {
            var            dt     = testConn.GetSchema("Tables");
            IList <string> tables = new List <string>();

            foreach (DataRow r in dt.Rows)
            {
                tables.Add(r["TABLE_NAME"].ToString());
            }
            return(tables);
        }
예제 #5
0
        public void A_connection_can_be_established_with_datastore()
        {
            using (SqlCeConnection conn = new SqlCeConnection(_connectionString))
            {
                conn.Open();

                _schemaInfo = conn.GetSchema();
            }

            Assert.That(_schemaInfo.IsInitialized && !_schemaInfo.HasErrors);
        }
예제 #6
0
        public void All_previously_existing_tables_can_be_dropped()
        {
            NHSession.DropAllTables();

            using (SqlCeConnection conn = new SqlCeConnection(_connectionString))
            {
                conn.Open();

                _schemaInfo = conn.GetSchema("Tables");
            }

            Assert.That(_schemaInfo.Rows.Count == 0);
        }
예제 #7
0
 public static List <string> GetTables()
 {
     using (SqlCeConnection connection = new SqlCeConnection(_connstring))
     {
         connection.Open();
         DataTable     schema     = connection.GetSchema("Tables");
         List <string> TableNames = new List <string>();
         foreach (DataRow row in schema.Rows)
         {
             TableNames.Add(row[2].ToString());
         }
         return(TableNames);
     }
 }
예제 #8
0
        public void The_data_tables_are_created_upon_schema_export()
        {
            NHSession.DropAllTables();
            NHSession.ExportModelToDatabase();

            using (SqlCeConnection conn = new SqlCeConnection(_connectionString))
            {
                conn.Open();

                _schemaInfo = conn.GetSchema("Tables");
            }

            Assert.That(_schemaInfo.Rows.Count == 1);
        }
예제 #9
0
 /// <summary>
 /// 查询数据库中所有表的名称
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button1_Click(object sender, EventArgs e)
 {
     using (SqlCeConnection conn = new SqlCeConnection(dataPath))
     {
         conn.Open();
         DataTable data = conn.GetSchema("Tables");
         comboBox1.Items.Clear();
         foreach (DataRow row in data.Rows)
         {
             string name = (string)row["TABLE_TYPE"];
             if (name.Contains("TABLE"))
             {
                 comboBox1.Items.Add(row["TABLE_NAME"].ToString());
             }
         }
         if (comboBox1.Items.Count != 0)
         {
             comboBox1.Text = comboBox1.Items[0].ToString();
         }
     }
 }
예제 #10
0
        public override DataTable GetDataTable(string schema, string tablename)
        {
            try
            {
                using (SqlCeConnection sqlcon = new SqlCeConnection(ConnectionString))
                {
                    if (sqlcon.State != ConnectionState.Open)
                    {
                        sqlcon.Open();
                    }

                    SchemaTable = sqlcon.GetSchema("Tables");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(SQLTable);
        }
        public static DataTable Get_Table_Names()
        {

            SqlCeConnection cn = new SqlCeConnection(_connstring);
            DataTable dt = new DataTable();
            
            try
            {

                cn.Open();
                dt = cn.GetSchema("Tables");
                

            }
            catch (SqlCeException sqlex)
            {
                MessageBox.Show(sqlex.Message, "fail");

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                cn.Close();


            }

            return dt;
            
        }
 public static List<string> GetTables()
 {
     using (SqlCeConnection connection = new SqlCeConnection(_connstring))
     {
         connection.Open();
         DataTable schema = connection.GetSchema("Tables");
         List<string> TableNames = new List<string>();
         foreach (DataRow row in schema.Rows)
         {
             TableNames.Add(row[2].ToString());
         }
         return TableNames;
     }
 }
 private static IList<string> GetTableNames(SqlCeConnection testConn)
 {
     var dt = testConn.GetSchema("Tables");
     IList<string> tables = new List<string>();
     foreach (DataRow r in dt.Rows)
     {
         tables.Add(r["TABLE_NAME"].ToString());
     }
     return tables;
 }
예제 #14
0
        private void SQLCESchema_Click(object sender, EventArgs e)
        {
            try
            {
                using (var conn = new SqlCeConnection(txtSqlCeConn.Text))
                {
                    conn.Open();
                    //string[] restriction = new string[] { txtOrclOwner.Text };

                    DataTable schema;
                    if (txtSqlCeSchemaName.Text.Length > 0)
                    {
                        schema = conn.GetSchema(txtSqlCeSchemaName.Text);//, restriction);
                    }
                    else
                        schema = conn.GetSchema();

                    grdGrid.DataSource = schema;
                    grdColumns.DataSource = GetColumns(schema.Columns);
                }
            }
            catch
            {
                throw;
            }
        }