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.
Related
I have a VB.NET program that I wrote 20 years ago and last updated 7 years ago. I have gotten a new computer and new version of Visual Studio recently.
The program uses a DB created with MS Access via the OLEDB mechanism. I originally created the DB connection by dragging and dropping tables from the DB into a VB window. This generates a lot of code automagically that I have never had to look at in the past. This code takes care of the DB queries and updates. Code I have explicitly written adds, modifies or deletes rows from the tables.
In the past I have been able to manually add a column to the Access DB and get the automatically generated code to update and make that column available to my code.
I am trying to do that now and I've either forgotten a crucial step or the newest version of Visual Studio is not compatible with my ancient code. The symptom is the new column does not get updated when I update all the other columns. If I look at the automagically generated code (in routine InitilizeComponent) it has lines like:
Me.OleDbUpdateCommand5.CommandText = resources.GetString("OleDbUpdateCommand5.CommandText")
Me.OleDbUpdateCommand5.Connection = Me.dcWageLossDB
Me.OleDbUpdateCommand5.Parameters.AddRange(New System.Data.OleDb.OleDbParameter() {New System.Data.OleDb.OleDbParameter("CaseId", System...
where in the arguments of the last call it lists all the columns EXCEPT for my my new one.
Note that while the new column does not get properly added to the DB queries, it does get added to internal structures so that in my code I can refer to the new column by name and set its value.
I know this question is rather fuzzy. It is not practical to provide the (quite long and complex) code. Since the problem probably depends on the long history, it also is not practical to try to create a small simple version of it.
I'm just hoping someone has run into this problem and knows the solution.
Thanks
I have already tried graphically deleting and adding back all the tables in the .xsd file used in the query via the solution explorer - data connections. It didn't help.
In desperation, I also tried modifying my hand the automagically generated code, adding it the new column in a fashion similar to what it had for all the old columns. I couldn't make that work.
I have a fairly complex database that has worked for quite a while. Today I went to troubleshoot something and I got a non-sensical error.
In my macro, first I create detail tables. Then I number each row sequentially in the detail table with a VBA script. Then I create a summarized version of that table including the just the key info like SKU and row number. (The rest of the details are added back later using the row number). The numbering script is working. The detail tables have the row numbers. However the summary table does not have the row numbers after running the macro. If I manually click the queries to add the summary tables, the numbers magically appear.
Please help. This database has worked for over a year without this problem.
Honestly it sounds like its corrupt. MS Access uses the Jet Engine which is known for bloating dB size and quite easily becoming corrupt.
You can see by the odd behaviour, the program is having trouble with the underlying file. If you open a new Access DB it won't exhibit the same problems.
The best bet is to recreate the dB from scratch or port it to SQL Server, PostGres, MySQL, SqlLite etc and put the application logic in a program - even if its a VB6 app, though I'd recommend .Net.
I've got the code to strip out every thing and recreate the MS Access dB here:
https://stackoverflow.com/a/16158027/495455
I created a Tabular model using VS 2013 (because later versions don't support BIDS helper (which we use for creating a folder structure organizing all measures and dimensions within the model)). After working on it for a while I noticed that I was missing a table, so I went back to go get it. The only mistake which I made was that I ended up creating a new data connection in the process. Short of dropping those tables and recreating them, is there a simple way for me to change the data source of that new table so that I can delete the redundant connection to my database?
A colleague shared the following link: http://jakubka.blogspot.com/2013/11/how-to-change-connection-string-for.html.
While changing the code in this way most certainly comes across as being hacky and is probably not the highly recommended way to do things; it worked! Took me less than 5 minutes to fix and it was as simple as described in the link...
Jakub K (author of the article), thanks, man!
I encountered this issue today. I have VS 2017 and co-worker showed me how to do this.
Create New Data source in the Model(.bim file)
Save and close .bim file
Right click the .bim file and view code . This gives you an editable view.
Edit the connection on all the tables you want changed, not the original connection.
Save and exist .bim file
Open .bim file and confirm change.
In this case I use Tabular Editor.
There is a good article about it Tabular Editor Tricks - Convert to Legacy
Hello everyone I'm using SQL Server 2008 Management Studio. When I change my database table and try to save changes I got this error
saving changes is not permitted.the changes you have made requires table to be dropped and re created.
And I found that by turning off the prevent saving changes option I can avoid this error. But my question is what are the problems I may face in future by turning off the prevent saving changes option? Is there any other method to avoid this problem?
If you turn off saving change i asume that no change will be made to the table. In my experience, SQL Server Management is not the best way to make changes to an existing table, especialy if got data on it. You will find many cases in wich gives you this error and you have to manualy write the ALTER TABLE to make the changes you want. So my advice is always to use ALTER TABLE. Hope this help.
Am I missing something here?
I've a .net 4.5.1 project with an Entity Framework model created from a SQL 2005 database (Connection type is SQL Server also), via "ADO.NET Entity Data Model".
This works fine. That is, until I update the database. If I add new tables or columns to existing tables all is well, but if I delete a column, the update just doesn't work properly. it also throws out errors when I alter the column type.
This same problem was reported a long time ago: http://blog.jongallant.com/2012/08/entity-framework-manual-update.html#.UytNrvldVD0, but it seems so ridiculous I can't believe I am not missing something. Surely I'm doing something wrong? How can I get the model to update properly?
I have the same problem. I opened up the Model, removed the changed tables from the diagram, then Updated from the Database and re-added the tables.
EF brought the table back in again with the correct structure. Save The model, Rebuild the project, everything turns up as expected.
I am not sure why it doesn't detect the deleted columns. I believe there's also issues if you change the data type of the columns, but I've not tested it. But the above solution has worked for me so far.