SQL Server 2000 data won't refresh

backeslash

New member
Joined
May 3, 2007
Messages
3
Programming Experience
Beginner
I'm having a problem updating my data sources in vb.net 2005. I'm getting my data from SQL Server 2000. It will connect and allow me to build with no issues, but when I make changes to the columns in SQL and refresh the data source, the changes don't show up (both large and small changes, such as changing the length, or adding a new column). Does anyone have any information on how to fix it or which one (SQL or Visual) is causing it? I'm getting really tired of having to start from scratch anytime I need to make a change to the sql table..
 
Yourpost uses terms too generic to determine what youre actually doing and what is going wrong. Please be more specific, listing the steps youre performing, what windows are open and what you do in them
 
I'm not sure what kind of detail is needed.. I create a new table on the SQL server, using Enterprise Manager. Then I go to VB .net, design the form, write all the code, and realize I need to make changes to the original table (such as adding a column, or changing properties). I close VB, go to the Enterprise Manager, and make the changes I need. Then I return to VB, and go to view data sources. I then right click to refresh the data sources and the changes I made in Enterprise Manager do not show up. So the only thing I can do is start from scratch again or remove all the data bindings and reconnect. I want to know if there is a way to avoid this, and simply have the table refresh. Hope that makes sense...
 
Last edited:
As far as I'm aware, VS takes a "copy" of your database structure when you create your dataSet.
Therefore making changes to the backend database will not automatically refresh your DataTables in your DataSet.

You don't need to start from stratch, all you need to do is configure the dataTable again, and this will then pick up any changes. If you've deleted a column or added a new one to your DB, you've have to check/uncheck this in your SQL Select query......
 
I'm not sure what kind of detail is needed.. I create a new table on the SQL server, using Enterprise Manager. Then I go to VB .net, design the form, write all the code, and realize I need to make changes to the original table (such as adding a column, or changing properties). I close VB, go to the Enterprise Manager, and make the changes I need. Then I return to VB, and go to view data sources. I then right click to refresh the data sources and the changes I made in Enterprise Manager do not show up.
No, they wont, because the contents of the Data Sources window are derived from the schema of one or more DataSet objects in your project. If your project has no DataSet, your data sources has no entries. If your project has five DataSets your data sources have five entries. DataSet is the client side temporary storage container for data downlaoded from a database. There is no mandate that it must be identical in structure to the database schema for which it serves, ergo it is allowed that a database table has columns that are not present in your data set

Go into the dataset designer and reconfigure all necessary datatables and/or tableadapters to use the new database columns

I want to know if there is a way to avoid this, and simply have the table refresh. Hope that makes sense...

When you make a tableadapter/datatable pair, the tableadapter wizard asks you for an SQL to use to derive the main structure. You probably wrote:

SELECT * FROM emp

Because the wizard cannot be doing with something as vague as *, it reads the schema for the table and converts your query to:

SELECT name, dept, salary, manager FROM emp


Now it can make a datatable of 4 columns, map these columns to the database and it will al always work unless you use the enterprise manager to rip out one of these columns or change the primary key. Add columns to the DB all you want, and the tableadapter wont care

If you want to use your new column, configure the tableadapter with a NEW query. Right click it and choose configure.. Add in the relevant column and the wizard should generate you a new datatable. It may then also ask you:

"You have changed the SELECT command, do you want to update the existing INSERT/UPDATE/DELETE commands based on the new query text?" or soemthing like that.. You can say yes if:

You have not customised them and are worried about your changes being lost
and
You need to send changes to the new column back to the database.


If you need neither of these, you can say no to this question
 
Back
Top