OK, I'm an old dog (slowly) learning new tricks and I need to see the cogs turning in order to understand what's going on.
I've generated an MVC3 app using EF4.1 from an existing database and the list in the MVC3 view (based on a SQL View) shows different results to the SQL View viewed in SQL manager. Specifically, fields from a joined table seem to not get updated between multiple hits on the main table.
The funny thing is: If I capture the sql that intellisense shows for the db.myViewClass.ToList() call and paste that into SQL manager, it gives the right results!
I've also created a mini test app and that works fine. So far I can't see how the test app differs from my main app which fails.
I'm frustrated that I can't step in to the code to see what's happening in db.myViewClass.
Any bright ideas anyone?
Dave.
Related
I am working on live support project for a web site. I just wrote the frontend and I created the table that I need in SQL Server and then I made a connection between SQL Server and my ASP.NET MVC project.
I watched many videos and I didn't get the part which I will start get the data from the models which are created when I made the connection I talked about.
To be clear: I wrote two Divs in web page one for the sender and one for the receiver and I give messages a variable called ̰"destination" in DB so if the value is 0 it will be insert the text in sender's div and if the value is 1 it will be insert the text in receiver's div.
The problem that I know the logic but I don't know how to apply it. Please can anyone help me and tell me how to do it? Or what is the Technique that I should work with?
You should start looking into Entity Framework to get the data from the database. I think for now you should use Database First approach which is very easy as compared to Code first approach.
To start with Database first just add new item and select ADO.NET Entity Model . This will launch the wizard where you can select EF designer from database and then you can give the connection string and all the databse you want to use
Refer below link for explanation.
http://debugonweb.com/2020/01/crud-operation-using-database-first-approach-asp-net-mvc/
I created a database-first M.V.C. library application with three tables: Members, Books, and Checkouts (which links them all together). I used MSSQL to create the database; then I linked the tables to my application in Visual Studio using the A.D.O. Entity Framework.
When I run the application and add data, everything seems to work just fine.
But when I go back to MSSQL to perform queries (SELECT * FROM Members), the fields populate--but not any of the data I just entered in the web site!
Any ideas as to why it's doing this?
I figured it out.
For anyone else who has this issue, stop creating a new data context class when you add the controllers. Select the one that's already in the drop-down list. Problem solved.
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.
I have just started an internship in I've had to learn a lot on my own. I'm learning MS SQL Server, but having a strange problem. I have a DB that has four small tables. Each one has a script to drop the table, recreate the table (I've avoided FK dependencies for the time being), and execute a demo query.
Problem 1: When I first started SQL Server Managmenent Studio would execute the script, but one table didn't show up in the Object Explorer. If I tried to execute a demo query from the same .sql file, it executed with no problem. If I tried to access it from another .sql, the table didn't exist. After many times of successfully executing the script, it finally just showed up.
Problem 2: Similar problem. When I updated one table, the changes wouldn't be reflected in queries.
Problem 3: Queries will fail, but if I click execute again with no changes being made, it will usually work correctly.
Problem 4: When I use an alias for a field name, sometimes the alias is recognized and sometimes it isn't. I've literally had single query in which the alias would work in one place, but not work in another and I had to use a fully qualified name.
I've tried the refresh and refresh local cache, but those seem to have no effect. If I exit Management Studio, that seems to usually fix the first two problems.
Am I going nuts or am I just in the dark about some weird specifics of SQL Server?
First of all, when you make a schema change you need to right-click on the "Tables" node for the database in management studio and hit refresh.
If you change a column or something in a table, right-click the table and refresh.
The refresh local cache only updates the intellisense stuff, and the refresh only updates the GUI. If you modify a table with SQL and do not refresh it in the UI, the query can still use the updated table.
If you query fails, you either have a bad query or it's not pointed at the database or connection you think it is.
For aliases, there are places where they will not work (update statements, for example) but if you don't post queries where they don't work we cannot read your mind and tell you what's wrong.
If you have specific queries that are failing, post them.
This is driving me insane. I am trying to get a basic Report to show with Report Viewer but cant get the DataSet to show in the Website Data Source window no matter what I do.
I created a dataset..picked the proc I want, etc. without any problems. I added my RDLC and tried adding a table that I can bind data to but the Windows that contains the Data Sources is empty.
Im using VS 2008. Is there anything im doing wrong? Ive followed some tutorials but cant get further due to this issue.
Ok..figured it out after wasting 1 day on it.
As I said i am running VS 2008 and what I did was remove all the DLL references one by one until the window populated with some datasources. I found out a reference to Entity Spaces cause the problem. So I create the reports and when im down add back the reference. A pain but it now works.
Jeeesh.