Click here to Skip to main content
15,912,207 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a project in vb with connect ms access datbase..but i want to change column name, Rename and add something...

So my datagridview1 also so that value changes... how it is work....

What I have tried:

i have delete old ms access database and edit something in that again i had to include ms access database but that was not work...
Posted
Updated 24-Oct-19 23:39pm
Comments
Richard MacCutchan 25-Oct-19 5:05am    
As I already suggested, please provide full details including the code that is not working.

1 solution

Renaming columns is a drastic step: it affects all applications that use the data, and may require a lot of changes to a lot of code - or they will stop working because the old column names no longer exist. Unless this is a new project, and you need to change the names because you have redesigned its function, then I'd strongly suggest you don't do it.

You can use different names in your DGV just by requesting it under a different name:
Instead of
SQL
SELECT PN, desc, RP FROM Products
Use this:
SQL
SELECT PN AS [Part #], desc AS [Description], RP AS [Retail Price ($)] FROM Products
and the "human readable" names will be used as column headers in your DGV.

If you need to change column names in your DB, I'd suggest you do it in Access itself, rather than your app - it's a lot less prone to causing strange crashes! But ... you can do it with the ALTER TABLE statement (Microsoft Access SQL) | Microsoft Docs[^] - it's just very unusual to do it on a regular basis.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900