Click here to Skip to main content
15,885,159 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hey, is there any way to change a column name of a table that is equal to a name entered in a check box ? i want to add columns to my table using system date. so the column name will be system date. any methods guys ?
Posted
Updated 9-May-15 8:40am
v2
Comments
You just need to execute a query with the name, what is the issue?
Aruna Usitha 9-May-15 23:06pm    
sir i wan't this to be executed daily. the query will be an automated one
Maciej Los 9-May-15 14:40pm    
What have you tried? Where are you stuck?
What kind of table?
Aruna Usitha 9-May-15 23:08pm    
this table contains attendence of emloyees the coulumn is the date and the data in a column would be the names of employees present that date.

i tried this code

dbmem = New SqlCommand("CREATE TABLE new( '" & Label1.Text & "' varchar)", conn)

1 solution

Creating columns with dates as their name is a very bad idea and a very bad design. However, there is no other reason you cannot do it. You'll want to strip out special characters such as "/" and "-" so you'll want your dates like 20150509, for example.

I would strongly suggest you rethink your database design and have a table that stores the date in one column and then the employees in another column and create a record for each employee on each date that you need.
 
Share this answer
 
Comments
Aruna Usitha 9-May-15 23:56pm    
thank you for your answer sir
ZurdoDev 10-May-15 0:00am    
You're welcome.

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