简体   繁体   中英

How to concatenate two columns from MySQL DataTable in the Datagrid View of Visual Studio 2019?

I'm sorry if my question is quite simple, I am a college student trying to explore database connections in visual studio. I was able to display values from my database table in the datagrid view but I was wondering how to concatenate two columns and make them appear as one in the textbox. Thank you very much to anyone who can help me. I am currently using the C# language.

You can concatenate the column in MySql and use the Alias as biding to the grid. So in the below example, you can bind the grid column with Address.

SELECT CustomerName, CONCAT(Address, " ", PostalCode, " ", City) AS Address
FROM Customers;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM