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

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/

Related

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

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.

vb.net bound controls with web service

Here is the scenario. Two networks need to talk to eachother. I have an app that has a local database in our environment that the app talks too. It is using bound controls on a datagrid using vb.net. Now we want to move the database to the other network and the only way we can have access is this network is using web services. I have a datagrid that is bound to a database and employee table. The vb.net code using the fill function and dataset embedded sql to display. The save function has code such as me.validate() and .endedit() and then uses the update method to update the database from the grid. I need to strip this out and put it in web methods. What is the easiest way to do this. I know the fill is basically a select statement i can retrieve and return a datatable from the web service, but what would be the easiest way to save from the web method. any ideas would be appreciated. unfortunately this is the way it has to be from the network standpoint.

Pulling Data From an SQL Database in HTML 5

I am trying to develop a BlackBerry application that will show data from an SQL Database from a server. I was researching the new HTML 5 option for blackberry (WebWorks) and noticed that it apparently cannot connect to any server data by itself. Some links state that I would need javascript coding to obtain it. I looked into the option of PhoneGap (link here: http://phonegap.com/) and decided I'd try using HTML 5 to produce the application. I have never touched SQL databases before and I am wondering how I would connect the two; meaning how do you pull data from the server given that you are working with HTML5?
I have looked at:
Where is data stored when using an HTML 5 Web SQL Database
Process for pulling data from a sql database
among others but I am still unsure as to what to do. I would be looking to "view" the data from the server and display it on the app. It would be something of the sort:
- HomeScreen: What data would you like to view?:
- Dropdown list of categories (from the database)
- Selecting Entry in dropdown leads to available information (from the database)
Any help would be appreciated, and of course thanks in advance.
the new (and pretty awesome) features of HTML5 is happening in the browser on the client side. What you will need is a back-end on the server side doing some magic. It is true that browsers now have databases but these are located on the phone, computer etc and as I understand your question you want these data to communicate with data on your server. To move data across the web you will need to perform HTTP-requests which can easily be done through javascript and ajax. Look a bit into these technologies and make a little server-side script that gathers data from the database and send it in a structured format to the phone (JSON, XML), then make a script in javascript on the client-side that parse these data and utilise them.
Good luck!

How to create a aspx form

I wanna create a aspx form where it should connect with a HTML form and how should i display it in vb.net..
also when click the link, the form should fill with data automatically where the data should retrieve from microsoft sql database and display it without any error...
Question is kind of broad one. But you can use asp.net form view to show the data from the database and you can access it from the server side code(VB.Net).
http://www.learn-asp.net/asptutorials/FormView.aspx here is a good article for you.
I did not understand very well! but I guess you want to create a ASP.NET page with vb.net.right?
If I'm correct, steps are depend on your version of Visual studio but the only thing you need is create website project!
Second question:You should First retrieve data from your database
Here is good article: Click.
If I misunderstood, let me know!

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.