Add column to database

1k views Asked by At

I'm working with ASP.NET in Microsoft Visual Studio 2010. When I did my database I had Microsoft Access. Now I don't have it (have tried to get it), so I thought that the best idea is to change my table with code. I want to add a column to my table that can fit pictures. How do I do it? I thought that I do an .aspx file(Webpage), then in the .aspx.cs file I write my code. I run it once changing my table and have what I want and delete that file. Is there another way without other programs?

My table is called item and I want to add the column that can have a picture. What's the code for that? Thanks!

2

There are 2 answers

2
laskdjf On BEST ANSWER

You can use the ALTER TABLE Command:

ALTER TABLE item ADD COLUMN picture varbinary
0
fieora On

Well, you can add the column using SQL, which I am assuming you are familiar with.
ALTER TABLE table_name ADD column_name column-definition;
So that is something you would want to run 1 time and make sure you define the column correctly;

Alternatively, you can edit the Table Definition from the server explorer by right clicking on the table and clicking table definition. Then you can add or change what ever you like.