Click here to Skip to main content
15,885,172 members
Articles / Web Development / ASP.NET

CRUD tables in WebMatrix using jTable jQuery plugin

Rate me:
Please Sign up or sign in to vote.
4.87/5 (12 votes)
23 May 2013CPOL4 min read 94K   2.4K   31  
A working example of a jTable implementation in WebMatrix 3
@{
    try
    {
        var order = Request["Order Id"];
        var name = Request["Product Name"];
        var price = Request["Unit Price"];
        var quant = Request["Quantity"];
        var db = Database.Open("Orders");
        db.Execute(@"INSERT INTO Details ([Order Id], [Product Name], [Unit Price], [Quantity]) 
                VALUES (@0, @1, @2, @3)", order, name, price, quant);
        var detail = db.QuerySingle("SELECT * FROM Details WHERE [Detail Id] = @0",
                db.GetLastInsertId());
        var json = Json.Encode(new{Result = "OK", Record = detail});
        Response.Write(json);       
    }
    catch (Exception ex)
    {
        var json = Json.Encode(new{Result = "ERROR", Message = ex.Message});
        Response.Write(json);
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer Federfarma Pavia
Italy Italy
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions