Пример #1
0
        private DataTable [] GetColumnMetaData()
        {
            DataTable [] columnMetaDataTables = new DataTable [2];
            SqlCommand   cmd = new SqlCommand("select @@trancount; " +
                                              "set fmtonly on select * from " +
                                              DestinationTableName + " set fmtonly off;" +
                                              "exec sp_tablecollations_90 '" +
                                              DestinationTableName + "'",
                                              connection);
            SqlDataReader reader = cmd.ExecuteReader();
            int           i      = 0; // Skipping 1st result

            do
            {
                if (i == 1)
                {
                    columnMetaDataTables [i - 1] = reader.GetSchemaTable();
                }
                else if (i == 2)
                {
                    SqlDataAdapter adapter = new SqlDataAdapter();
                    adapter.MissingSchemaAction  = MissingSchemaAction.AddWithKey;
                    columnMetaDataTables [i - 1] = new DataTable();
                    adapter.FillInternal(columnMetaDataTables [i - 1], reader);
                }
                i++;
            } while (reader.IsClosed == false && reader.NextResult());
            reader.Close();
            return(columnMetaDataTables);
        }
Пример #2
0
        public void WriteToServer(IDataReader reader)
        {
            DataTable      table   = new DataTable();
            SqlDataAdapter adapter = new SqlDataAdapter();

            adapter.FillInternal(table, reader);
            BulkCopyToServer(table, 0);
        }
Пример #3
0
		public void WriteToServer (IDataReader reader)
		{
			DataTable table = new DataTable ();
			SqlDataAdapter adapter = new SqlDataAdapter ();
			adapter.FillInternal (table, reader);
			BulkCopyToServer (table, 0);
		}
Пример #4
0
		private DataTable [] GetColumnMetaData ()
		{
			DataTable [] columnMetaDataTables = new DataTable [2];
			SqlCommand cmd = new SqlCommand ("select @@trancount; " +
							 "set fmtonly on select * from " +
							 DestinationTableName + " set fmtonly off;" +
							 "exec sp_tablecollations_90 '" +
							 DestinationTableName + "'",
							 connection);

			if (externalTransaction != null)
				cmd.Transaction = externalTransaction;

			SqlDataReader reader = cmd.ExecuteReader ();
			int i = 0; // Skipping 1st result
			do {
				  if (i == 1) {
					columnMetaDataTables [i - 1] = reader.GetSchemaTable ();
				  } else if (i == 2) {
					SqlDataAdapter adapter = new SqlDataAdapter ();
					adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
					columnMetaDataTables [i - 1] = new DataTable (DestinationTableName);
					adapter.FillInternal (columnMetaDataTables [i - 1], reader);
				}
				i++;
			} while (reader.IsClosed == false && reader.NextResult());
			reader.Close ();
			return columnMetaDataTables;
		}