Wednesday, December 14, 2016

Cannot implicitly convert type 'string' to 'System.Windows.Forms.DataGridViewTextBoxColumn

If you get the above error message when developing a .NET application, then you have most probably set as a column name for one of your datagridview column the reserved word 'name'.

Cannot implicitly convert type 'string' to 'System.Windows.Forms.DataGridViewTextBoxColumn
Example of Exception in Visual Studio when Using the Reserved Word "Name" as a DataGridView Column Name.

If you do this, then the compiler finds a conflict between the assignment of the form's name and the DataGridview's column name.

To resolve this issue just change the name of the DataGridView's column to something else instead of "name".

There is a reason there are reserved words not only in .NET byut in many other development platforms as well (i.e. SQL Server, etc.).

To this end, please make sure that you are not using any reserved words in your development work because if you use them, there is always the risk of a conflict with system routines like the above example.

Check this MSDN article for information about the words reserved by the linker.

The SQL Server and .NET Hub

Reference: The SQL Server and .NET Hub (http://www.sqlnethub.com)

For more articles click here!


[Ads]
Check out my latest eBook on SQL Server:
Tuning SQL Server - Ebook

Easily secure your SQL Server instances! Try out DBA Security Advisor!
DBA Security Advisor for SQL Server by SQLArtBits
DBA Security Advisor was developed by SQLArtBits. The tool was being carefully developed for an entire year and it contains comprehensive security checks and recommendations based on proven SQL Server security best practices. Feel free to download and use the Community Edition which is free and if you find it useful, you can consider upgrading to the Enterprise Edition!

Artemakis Artemiou [MVP]

Author & Editor

Artemakis Artemiou is a Senior SQL Server Architect, Software Developer and Microsoft Data Platform MVP. He is also an author, regular blogger, president of Cyprus.NET User Group and CY Country leader of INETA-EU. He is also the creator of DBA Security Advisor and In-Memory OLTP Simulator. Artemakis is a frequent guest author of worldwide well-respected online journals where he writes articles focusing on many SQL Server topics.

Reference: The SQL Server and .NET Hub (http://www.sqlnethub.com)

0 comments: