Member Avatar
CriticalError

I have a column called pEditDate in the table rc_Pages I need to extract the date for each page so when the users goes to page /example the last edit date shows at the bottom. I try to do is but can't. Using SQL Server Comptact and C#

What have you tried, and what is your table structure ?

Member Avatar
CriticalError
var SQLSELECT = "SELECT pEditDate FROM rc_Pages";
var db = Database.Open("razorc");
var data = db.QuerySingle(SQLSELECT, false);


<span style="color: #f00">Last Edit Date: <b>@data.pEditDate</b></span>

This works but it is the same date for every page, someone said I need a WHERE clause so I can get the page id or something but I dont know this, is asp.net webpages. And I do not know what you mean by Table Structure

Yes, if you want the date for the page, you will need to specify the id for that page. So, I hope you have it somewhere available in a variable. If you do, then you can add the WHERE clause to your SQLSELECT string, so it gets the date for that particular page.

Member Avatar
CriticalError

Each page does have an id in the column pId however I simply do not know how to say for this page get its date time. I can't figure it out. Look at my website http://www.thecodingguys.net

For my subdomain website http://razorc.thecodingguys.net I managed to get the date for each page easily since each page is based of tha wiki?id=ID

  var pId = Request["pId"];
        var db = Database.Open("RazorC");
        var SQLSELECT = "SELECT pEditDate FROM rc_Pages WHERE pId=@0";
        var data = db.Query(SQLSELECT, pId);


        var pEditDate = data.pEditDate;

I got that so far and it says:

CS1061: 'System.Collections.Generic.IEnumerable<dynamic>' does not contain a definition for 'pEditDate' and no extension method 'pEditDate' accepting a first argument of type 'System.Collections.Generic.IEnumerable<dynamic>' could be found (are you missing a using directive or an assembly reference?)

Try the old-fashioned way:

var SQLSELECT = "SELECT pEditDate FROM rc_Pages WHERE pId=" + pId;
Member Avatar
CriticalError

Solved it using this code:

 var pageName = Context.GetRouteValue("rcPageName");
    var db = Database.Open("razorC");
    var selectQueryString = "SELECT pId, pName, pEditDate "
                            + "FROM rc_Pages "
                            + "WHERE pName = @0  AND pSiteMap = 'True'";


    var data = db.QuerySingle(selectQueryString, pageName);
    if (data == null) { Response.Redirect("~/rcError"); }

    string format = " dd MMMM yyyy - hh:mm:ss tt ";

    var editdate =  data.pEditdate.ToString(format);

Thanks for your help though.