Why aren't my records showing up in MSSQL when I perform SQL queries? - sql

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.

Related

Get data from the db to the view page in ASP.NET MVC

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/

can't find SQL code for XSD schema tables

The following snippet below came from a *.xsd (XML Schema built in Visual Studio) file. I'm trying to figure out where the SQL code lives for the data that can be retrieved with these Strongly Typed .NET tables. I looked everywhere, and cannot find it. Only two of the tables match actual table names in my database. Are these primary and foreign keys configured in Visual Studio for this XSD or are these keys found in the SQL database? If I double click the *.xsd, I can see the tables, but I don't know what data is queried from the database unless I use the SQL profiler. If someone can explain, that would be great.
Found this PDF to be the best resource online so far:
http://oreilly.com/catalog/visualstudiohks/chapter/hack49.pdf
Strongly Typed Datasets starts on page 49. The only problem is that it isn't helping me answer the question I had. When I drag a table from the Server Explorer to the *.xsd file, a TableAdaptor gets created with a method called Fill,GetData(). When created manually, this doesn't get created. It also says it automatically updates the web.config file with connection string information. However, the tables I'm trying to figure out don't have this TableAdaptor. The keys don't seem to be related to SQL at all. They are purely based on the Table in the Visual Studio XSD Designer based on columns created there. I'd still like to know how the data is ultimately mapped to SQL and to what tables.

Puttting together binding navigators in a project

I am working on a group project in vb.net, in which all my team members are working on individual tables of a database. All of us are using binding navigator,where the GUI is created by drag and drop from the table.
Is it possible to attach all these pieces together with imports or references?
Will the changes made to the database while working on the program like table adapter can create problem? Do I need to make all those changes in database before importing ?
Can you please give suggestions to put the project together.
By binding the particular combo box to the original table the data need not be re-entered in that particular combo box.It appears at run time. I think my question was not clear that is why I did not get any answer

FluentNHibernate: Getting the Examples.FirstProject to work

Im trying to get the most basic of examples to run in FnH. I started with the Examples.FirstProject. However, I did not use the SQL lite configuration. Instead, I set the configuration to SQL2005 and created the tables as was diagramed in the example.
When stepping through the code, there appears to be no problems when creating the session factory. I do receive an error however when the code reaches the "transaction.commit" line. The error reads:
Could not insert collection: [Examples.FirstProject.Entities.Store.Products#5][SQL:SQL not available]
Im wondering if there was an issue with the way the tables were created in SQL Server. The IDs were "int" type and the names and such were "varchar(50)." I set the PK of Store, Product, and Employee to its respective ID field. I also made the ID increment automatically by 1 (IdentitySpecification column property in SQL Server). StoreProduct is the many-to-many and is also there per the diagram.
Any help would be appreciated. Thanks.
Have you modified the sample in any way other than changing the database provide? Have you been able to save any entities from the sample (ie if you remove the Products code and just save the Store)?
I developed this sample against SQLExpress, so I would imagine there wouldn't be any incompatibilities with SQL 2005.
Also, this question would probably be better be suited to the Fluent NHibernate mailing list, as Stack Overflow isn't great for these kind-of investigatory postings.
Thank you James. I'll look at using Fluent NHibernate mailing list. As a solution to my issue, I did simplify the example a bit and found that rebuilding the tables helped. In the previous attempt I built the tables in the Database diagram tool. That is where I think something was a little off. Just now I rebuilt them using the menus and still made the foreign key connections with the Database Diagram section. Worked like a charm. Thanks again and keep up the good work with FnH.
First thing to check: Are you sure that you have really created a correct table in SQL server, and that the schema is correct? You can verify this by using SQL Express management studio to view the sql database.

Loading an existing database into WWW SQL Designer?

I've used WWW SQL Designer several times to design databases for applications. I'm now in charge of working on an application with a lot of tables (100+ mysql tables) and I would love to be able to look at the relations between tables in a manner similar to what WWW SQL Designer provides. It seems that it comes with the provisions to hook up to a database and provide a diagram of its structure, but I've not yet been able to figure out exactly how one would do that.
I know this is really old stuff, but I found the solution (if people are looking for it) : you have to edit the file backend/php-mysql/index.php and fill the connection settings. All you need is then to click on Import From DB, and then Load with the name of your database.
function setup_import() {
define("SERVER","localhost");
define("USER","");
define("PASSWORD","");
define("DB","information_schema");
}
http://code.google.com/p/database-diagram/
This takes a SQL structure (SQL dump) and shows a diagram :)
Can you just export the sql query that builds your existing tables, and run that in WWW SQL Designer? Most database management software has that option...
Looking at the interface of the designer, I guess that when you run it on your own PHP/MySQL server, you should be able to import existing database with "Import from DB" button in Save/Load dialog.
You could use VISIO to import the database, it will diagram it for you.
btw, have you tried SchemaBank? They are web-based and support MySQL fairly well. It eats your sql dump and generates the tables and relationships for you.