Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • William Heafner 1 post 21 karma points
    Jan 14, 2015 @ 21:59
    William Heafner
    0

    How do I display data from my SQL CE database using Razor syntax

    I have the following razor code on a .cshtml page in WebMatrix which works fine. How do I accomplish the same results using Umbraco?

    @{
      var db = Database.Open("listings");
      var selectQueryString = "SELECT * FROM ads WHERE (Category = N'Rentals') ORDER BY PositionSort ASC";
    }
        @foreach(var row in db.Query(selectQueryString)){ 
            <div itemscope itemtype="http://schema.org/LodgingBusiness" class="walk-listing">
            <div class="photo">
                <a href="@row.URL"    rel="nofollow" target="_blank"><img src="@row.Photo_1" alt="@row.title" title="@row.title" /></a>
            </div>
            <div class="summary">
                <h2><a href="@row.URL" itemprop="name" rel="nofollow" target="_blank">@row.Title</a></h2>
                <div class="walk-meta">
                    <span class="location"><i class="icon-map-marker"></i> <strong>City/State - </strong>@row.City, @row.State</span><br />
                    <span class="location"><i class="icon-map-marker"></i> <strong>County/Region - </strong>@row.County, @row.Region</span><br />
                    <span class="priceRange"><i class="icon-map-marker"></i> <strong>Rates - </strong>@row.Rates</span><br />
                    <span><i class="icon-map-marker"></i> <strong>Pet Friendly - </strong>@row.Pets</span>
                </div>
                <div itemprop="description" class="walk-summary"><strong>Description - </strong>@row.SDescription</div>
                <div itemprop="url" class="walk-meta-options"><i class="icon-heart"></i> <a href="@row.URL" rel="nofollow" target="_blank">Visit Website</a></div>
            </div>
        </div>
    }
    

     

  • Dennis Aaen 4457 posts 17970 karma points admin hq c-trib
    Jan 14, 2015 @ 22:16
    Dennis Aaen
    0

    Hi William and welcome to our.

    What you could do is create a custom table in the Umbraco database, then store the information there and use this in your Umbraco installation.

    Aptitude has made a video http://www.aptitude.co.uk/videos/using-custom-tables-data-in-umbraco/ on how you could do it, maybe it would benefit to see the video and after that try do something similar.

    Hope this helps and could be a solution for you,

    /Dennis

  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    Jan 15, 2015 @ 12:46
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies