Changes in SQL tables and databinding

B

Bob

I had a SQL server 2005 table in which I noticed I mispelled a column name.
I changed the column name in the sql server table but after that, in the UI
fortm using the table, the dataset control bound via a binding source and a
table adapter to a datagridview no longer recognized the changed column name
and kept giving me an error on that column, evidentlty I expect that is
normal.
But only way I found to fix and see my changed column was to remove the
datagridview using it and all its associated controls (dataset, etc..) and
create a brand new datagrid with its associated dataset binding source and
table adapter.

Questions is there must be a simpler way to effect changes in the objects
related to databinding controls in the UI when a change is brought to the
underlying SQL server tables. How do you get these controls to get the new
table definitions without having to reprogram your entire form?

Any help appreciated,

Bob
 
P

Peter Huang [MSFT]

Hi

Based on my understanding, you have a SQL Table and binding to the
DataGridView.
Now you want to change one column name in SQL Table and you did not want to
change the code.

So far I did not know in what extent did you reference the column name in
your program.
But here is an approach you may have a try.
e.g.
You have a column Name: fname and code your program.
Now you want to change the Column Name to EmployeeName.

1. Open the dataset designer by doubleclick the xsd file in the solution
explorer.
2. right click on the TableAdapater and click configurate
3. Change the Select statement to employeeName from fname because we have
change that in SQL Table
4. Save, and the Table mapping in Dataset Designer will be changed into
employeeName
5. to apply the original name, please change the employeeName back to fname
6. Save and rebuild the solution.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
C

Cor Ligthert [MVP]

Bob,

It is much improved in Version 2005 comparing with Versions 2003 and before.
In those you had to start new when you used the designer (and therefore it
was probably hardly used, I will be curious what it will be with the new
one, however that looks much better because you can recreate your table by
adding columns and changing names in the XSD dataset etc (the retrieving
commands are now in the dataset it self))..

I am really curious if the way Peter shows work, I would not know why not.
However, maybe can you reply if you succeeded with that.

Thanks,

Cor
 
B

Bob

Thank you both, I will test this immediately and give you a reply on how
well it worked.
Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top