SSMS New Database Diagram using cached data? - ssms

When I try to use the New Database Diagram tool in SSMS, it appears to use old cached table data. Columns and keys that I have dropped from tables somehow continue to appear in the diagram. When I select the tables for the diagram, I hit the Refresh button, but the problem still occurs.
I have checked [INFORMATION_SCHEMA].[COLUMNS] and the dropped columns are not there anymore. I have refreshed the Object Explorer as well, by right clicking the database and selecting "Refresh".
How can I force the tool to clear its cache? Or is something else happening?

I just had to restart the application.

Related

Fixing a broken database .NET

Okay so I am working in Web Forms but the problem would also apply to MVC I am assuming since both have the option of creating a users database on project creation. I deleted a data table on accident and updated the database instead of deleting the database itself because I was trying to recreate it with the seed data. I didn't realize that deleting a data table would do something different from deleting the database itself. The only backup I have is pretty old, so I would prefer to use a different way to fix things if that exists. How would I fix things?
I have it working now. What I did to fix it was I went to my back up although it could have just been a brand new project, both would have been fine, and I copied the SQL script for the data table that I deleted. Then I went to my broken program and created a new data table in the spot where it was before and replaced the code with the code from the back up. I saved it and hit update and it updated the database for me.

Local Database: Not loading all the changes of the tables and views

I am using Visual Studio 2012 and an SQL Server Database.
At first, my program loads all the tables as well as views but when I try to do some modifications to the database schema (e.g. add some views) the changes are not reflected when I deleted the connection in the Solution Explorer-Model and then reconnect it.
I tried to delete the connection again, load the database and reconnect, but still, I get same results.
Why is this so? Any idea?
First, I make a database by clicking App_Data and add new Item. I add SQL Server Database. So that's why the entities has a .mdf extension.
Next, I add new tables on the database by right clicking the "Tables" and Add new Table on it. Insert new columns as well as the keys.
Then, I connect to the database by Right clicking Model in the Solution Explorer and add ADO.Net Entity Model. I used the Database.mdf for my connection. After that, it automatically generates the connection string in the web.config as well as the diagram.
Usually, when I made some changes in the database, I deleted the connection and reconnect again. Before I had no problems with it. The changes were seen upon reconnection but this time when I tried using with another app, I'm wondering why the modifications were not seen. I tried many times to connect and delete again the database but still nothing works.
As I understand you, you works directly with .mdf file. Consecuently, each time when you starts your application it copies into Debug folder and if you work with this local copy (it depends on your connection string in App.config) you change data exactly in Debug folder. So, each time you erase your changes when application starts, try to changes your connnection string.

EclipseLink and JPA columns of table not showing up

In Eclipse, I try to create entity classes based on an existing database schema.
The wizard works until the end and creates the appropriate classes.
Except for one thing. Some classes are not being found by code as they're not generated.
In the "Customize individual entities" dialog, all the tables show up. Some of them don't have any columns being displayed in this dialog.
What works:
I can create relationships, even to these "missing" columns
I see these tables in Eclipses "Data Source Explorer"
The exact same columns don't appear in the JPA conversion dialog. The table has no arrow to further expand the item in the GUI.
I've already created a new workspace - without the success I'm looking for.
Why?
I'm using Microsoft SQL Server with the original sqljdbc4.jar
Although I have no idea why it happens, I finally know how to fix it:
In the Data Source Explorer, just expand the nodes in the tree until you see all the tables and their respective columns.
Somehow, they don't get loaded in the wizard. But they seem to do when opened in the data source explorer.
Afterwards, they also show up in the wizard.
Disconnecting and reconnecting using the Data Source Explorer fixed it for us.

Avoid replicating DELETE statements in SQL Server

Consider the following scenario:
One PC is running an Access database. An old legacy script will copy over all the contents from this Access database to a SQL Server (A) over LAN. But before it does this, it will delete all contents from the destination database, so it doesn't have to deal with existing records. Previously existing records are never altered.
On the SQL Server (A), replication is defined and it acts as a publisher. It will publish/replicate the data to SQL Server (B) over WAN.
This all works very well, but the only problem I'm facing is when there's a problem during the copying of contents to SQL Server (A), SQL Server (B) will be empty or missing records, even the records that were replicated a long time ago.
There are two solutions I've already considered:
Adapt the legacy script to only copy over new records, since the updates are incremental of nature.
Configure the replication to avoid DELETE statements.
The first solution is in this scenario not possible. The application is closed-source, and there's really nothing we can change.
The second solution would be ideal, but (A) would try to replicate records that already exist on (B), and I'm not quite sure how to handle that.
Surely there's a sound concept to this problem, I just haven't figured it out yet..
In SSMS go to Replication -> Local Publications and right click on your publication and select Properties. In the Publication Properties window click on 'Articles' and select the relevant article. Go to "Article Properties" and select "Set Properties of Highlighted Table Article". In the article properties window, change the "DELETE delivery format" to "Do not replicate DELETE statements".
After the change click OK and you will see a prompt. As the article property has been changed the subscriptions need to be reinitialized. Click "Mark for Reinitialization" which causes the snapshot to be applied to the subscriber.
In SSMS, navigate to Replication and right click and select "Launch Replication Monitor". Go to your publication and click View Details to see the snapshot progress.

Access front end GUI

I have a small SQL database, I want to make a front end GUI for it. VERY basic kind of stuff that basically just allows the user to input data into the GUI which basically just inserts data into the tables from the SQL database. I have the SQL database loaded into Access. I split the database which i think I was supposed to do?? Not sure If i was wrong let me know.
I think I need to usa Visual basic to make the page? I tried tinkering around but I cant seem to find the right instructions online. I basically am just trying to make an Access front end with a GUI that has a couple text boxes that the user will input data into, which will then save into the data to the back end SQL.
Anyone have any direction then can help point me? or if im am just COMPLETELY wrong in doing this that would also be nice to know lol I just thought Ive seen this done somewhere.
First off, your linked tables in Access that link to SQLServer should have the globe icons like this picture:
This means they're linked to the server rather than imported in as a copy of the data. Be sure the tables have primary keys, too; if they're heap tables (ie, no clustered unique index) then the linked tables will be read-only, because Access doesn't know how to send an update query to SQLServer. You can test this by opening one of the linked tables and trying to change data; your cursor won't do anything if it's a read-only table.
To create a super-basic entry form linked to a table, click Insert>Form, then right-click the little square in the upper-left corner of the form and click Properties like this:
Select the table that you want this form to do edits on in the RecordSource property as shown below. You can click the "..." to make a query rather than a single table for the edits, like if you need to join tables, but this gets more complicated because Access gets particular about what queries are still editable and frequently treats the query as read-only if you don't meet all the requirements (for ex, union queries will be read-only):
After you set the RecordSource, click View>Field List and you'll see the fields from the table like this:
Highlight these fields and drag them to the form like this (the unique key fields like ProductID should usually be made invisible, especially if they're autonumber fields, b/c the database will set these, not the user):
Click View>Form View, and you've got yourself an entry form. Use the left-right arrows at the bottom to move through the records, and the asterisk button to create a new record.