Question: My program loads data from a MySQL database into a `DataGridView`. I want to hide the first column (`id` column), but I get the reentrance cell error.

CODE:

```
void dataGridGlavni_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
    {
        if (this.dataGridGlavni.Columns[e.ColumnIndex].Name == "id")
        {
            this.dataGridGlavni.Columns[e.ColumnIndex].Visible = false; // <<<< error
        }
        if (this.dataGridGlavni.Columns[e.ColumnIndex].Name == "Plate za mesec")
        {
            GlavniForm.ShortFormDateFormat(e);
        }
    }

```

ERROR:

> 
> Operation is not valid because it results in a reentrant call to the SetCurrentCellAddressCore function.
> 
> 
> 

The error also appears when I use the following line:

```
this.dataGridGlavni.Columns[0].Visible = false;

```

However it does NOT appear when I use these lines:

```
this.dataGridGlavni.Columns[1].Visible = false;

```

OR

```
this.dataGridGlavni.Columns["Plate za mesec"].Visible = false;

```

I googled a lot and haven't been able to find the source of the error. What is happening why won't it let me hide the first column ?

Thank you

Answer: 
Worked perfectly for me to calculate **SQL database size** in **SQL Server 2012**

```
exec sp_spaceused

```

[![enter image description here](https://i.stack.imgur.com/jctbV.png)](https://i.stack.imgur.com/jctbV.png)
There are already a lot of great answers here but it's worth mentioning a simple and quick way to get the **SQL Server Database size with SQL Server Management Studio (SSMS)** using a standard report. 

To run a report you need:

1. right-click on the database
2. go to Reports > Standard Reports > Disk Usage.

It prints a nice report:

[![enter image description here](https://i.stack.imgur.com/joGAd.png)](https://i.stack.imgur.com/joGAd.png)

Where the **Total space Reserved** is the total size of the database on the disk and it includes the size of all data files and the size of all transaction log files.

Under the hood, SSMS uses [dbo.sysfiles](https://learn.microsoft.com/en-us/sql/relational-databases/system-compatibility-views/sys-sysfiles-transact-sql?view=sql-server-ver15) view or [sys.database\_files](https://learn.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-database-files-transact-sql?view=sql-server-ver15) view (depending on the version of MSSQL) and some kind of this query to get the Total space Reserved value:

```
SELECT sum((convert(dec (19, 2),  
convert(bigint,SIZE))) * 8192 / 1048576.0) db_size_mb
FROM dbo.sysfiles;

```