Click here to Skip to main content
15,891,704 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 94.1K   2.4K   31  
A working example of a jTable implementation in WebMatrix 3
@{
    try
    {
        var name = Request["Ship Name"];
        var country = Request["Ship Country"];
        var oDate = Request["Order Date"];
        var shipped = (Request["Shipped"] == "true" ? true : false);
        var db = Database.Open("Orders");
        db.Execute(@"INSERT INTO Orders ([Ship Name], [Ship Country], [Order Date],
                [Shipped]) 
                VALUES (@0, @1, @2, @3)", name, country, oDate, shipped);
        var order = db.QuerySingle("SELECT * FROM Orders WHERE [Order Id] = @0",
                db.GetLastInsertId());
        var json = Json.Encode(new{Result = "OK", Record = order});
        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