Interacting with database in MVC When using MVC 4 Razor (I am new to web development), I get concerned about my understanding of interactions between the database and the client. Much like all appilications these days, there is a lot of data that is presented to the user and in different fashions. I have looked around, and I can't find a concrete C# example, as they're mostly PHP.

Below is an example of loading data into a jQuery DataTables plugin. 


Is this the correct way of formatting data to JSON  and loading it into a jQuery function? 
If I wanted to update/delete/insert to the database from the client, is there a way to do that within JavaScript, or should I be doing it within C# somehow? (I have looked around and really, there isn't a ton of documentation)


Note: If it is easier to answer my question without concerning the use of jQuery DataTables, that's completely fine. I'm looking for a broader spectrum of information.

HTML

&lt;table id="grid" class="row-border hover order-column " width="100%"&gt;

    &lt;thead&gt;
        &lt;tr&gt;
            &lt;th&gt;Sequence&lt;/th&gt;
            &lt;th&gt;ID&lt;/th&gt;
            &lt;th&gt;Name&lt;/th&gt;
            &lt;th&gt;Ticker #&lt;/th&gt;
            &lt;th&gt;Salary&lt;/th&gt;
            &lt;th&gt;Bonus&lt;/th&gt;
            &lt;th&gt;Allocation&lt;/th&gt;
            &lt;th&gt;Begin Date&lt;/th&gt;
            &lt;th&gt;End Date&lt;/th&gt;
        &lt;/tr&gt;
    &lt;/thead&gt;
&lt;/table&gt;

&lt;div id="pager"&gt;&lt;/div&gt;


Home Controller - C#

    public string GetAssociateFromDb()
    {
        var dt = new DataTable();
        string connString = ConfigurationManager.ConnectionStrings["DEFCOMP"].ConnectionString;
        using (var connection = new SqlConnection())
        {
            connection.ConnectionString = connString;
            using (var cmd = new SqlCommand("SELECT * FROM FUND", connection))
            {
                connection.Open();
                var myAdapter = new SqlDataAdapter(cmd);
                myAdapter.Fill(dt);
                return JsonConvert.SerializeObject(dt);
            }
        }
      }


In the _Layout

&lt;head&gt;
        &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"&gt;&lt;/script&gt;
        &lt;link href="../../Content/jQueryDataTables1.10.css" rel="stylesheet" type="text/css" /&gt;
        &lt;script src= "http://cdn.datatables.net/1.10.0/js/jquery.dataTables.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;/head&gt;
I really feel bad about recommending this, but based on what you're doing you should investigate the use of Webforms in ASP.NET. 

Webforms are the most straightforward way to provide easy CRUD operations on a database in C# while exposing the operations safely to the user. You also will work entirely with C# and the ASP.NET elements in html, so there's no need to manually use javascript with most basic tasks. 

If you want to get more advanced then you can go with MVC5 in ASP.NET but that doesn't have the same level of builtin controls, data table displays, and similar that webforms has baked into itself. MVC5 does give you more power and flexibility in return, but if you need to get something done in a hurry or in a very basic form then you'll probably be fine with Webforms.

The problem with webforms, and why I feel bad recommending it, is that it tends to not encourage good N-Tier design because it both allows you to do things like embed SQL queries in your views (which is blasphemy) and a lot of the examples display exactly that behavior. 

It is possible to setup a good distribution of responsibilities into multiple tiers with webforms, which is what I'm doing at my current job, but it doesn't do a great job of encouraging good design. That being said, it does encourage getting things done in a hurry, so that can sometimes outweigh the drawbacks.