How to add a database field after the fact

acorn

Active member
Joined
Mar 8, 2008
Messages
32
Programming Experience
5-10
Hi there. I'm a newbie so I might be asking a silly question. I've created a databound datagridcontrol. I was able to create code to display and update my database data. However, I needed to add a new field to the database table. I'm having problems getting this data field to now show up in my dataset. I've opened up the designer for my dataset and tried to add the field to the existing dataset but adding a new column doesn't give me a chance to bind it to the field.
Can you help me out?
 
if you make any changes to the underlying database, you must make these changes MANUALLY in your dataSet(s). That means re-configuring them, and selecting the new column(s), or just going through the wizard if you've changed a column dataType.

Once this is done, you'll be able to bind the grid new column to this field.
 
Reconfiguring...

I tried to do the following:

Right click on my dataset, choose Configure Dataset with Wizard, and then select the table I want. But the system is saving it with a new name. Is there another way to do this? I hesitate to go through and manually update everything in case I miss some lines of code....

Thanks.
 
right click the dataTable, not the dataSet.

sorry, I kind of phrased it wrong in my first post.
 

Attachments

  • Image2.jpg
    Image2.jpg
    62.3 KB · Views: 37
Right clicking the dataset...

still does the same thing. It created another table in the dataset with a "1" appended to the end to make the name unique.
 
Right click the tableadapter under the table
Choose Configure
Go through the wizard, ENSURING THAT YOUR NEW COLUMN IS PRESENT IN THE SQL that the tableadapter selects its data with

It will appear by magic! :)
 
np.. note that though it appears now in the datatable (and think carefully about the questions asked like "do you want to change the Update/Insert/Delete commands to reflect the new column too" ) it wont appear in the datagrid you already put on the form (probably) because that datagrid populated its own Columns property when you dropped it on.. You'll have to manually add the column to the grid or delete the grid and drop another one on from the datasources window
 

Latest posts

Back
Top