Copied to clipboard

Flag this post as spam?

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


  • Nitesh 3 posts 73 karma points
    5 days ago
    Nitesh
    0

    Incorrect Syntax near '=' issue while reading Typed Media | CMS Version 7.2.0

    2018-12-06 11:24:19,670 [17] WARN umbraco.macro - [Thread 11] Error loading Partial View (file: ~/Views/MacroPartials/HomePromoBanners/HomePromoBannersMacro.cshtml). Exception: System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near '='.
    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds, Boolean describeParameterEncryptionRequest) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
    at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
    at Umbraco.Core.Persistence.PetaPocoCommandExtensions.<>c__DisplayClass4.b__3()
    at Umbraco.Core.Persistence.FaultHandling.RetryPolicy.ExecuteAction[TResult](Func1 func) at Umbraco.Core.Persistence.Database.<Query>d__1c1.MoveNext()
    at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
    at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at Umbraco.Core.Persistence.Repositories.MediaTypeRepository.PerformGetByQuery(IQuery1 query)
    at Umbraco.Core.Persistence.Repositories.RepositoryBase2.GetByQuery(IQuery1 query)
    at Umbraco.Core.Services.ContentTypeService.GetMediaType(String alias)
    at Umbraco.Core.Models.PublishedContent.PublishedContentType.CreatePublishedContentType(PublishedItemType itemType, String alias)
    at Umbraco.Core.Cache.CacheProviderExtensions.<>c__DisplayClass91.<GetCacheItem>b__8() at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Umbraco.Core.Cache.CacheProviderExtensions.GetCacheItem[T](ICacheProvider provider, String cacheKey, Func1 getCacheItem)
    at Umbraco.Core.Models.PublishedContent.PublishedContentType.Get(PublishedItemType itemType, String alias)
    at Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedMediaCache.DictionaryPublishedContent..ctor(IDictionary2 valueDictionary, Func2 getParent, Func2 getChildren, Func3 getProperty, Boolean fromExamine)
    at Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedMediaCache.ConvertFromSearchResult(SearchResult searchResult)
    at Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedMediaCache.GetUmbracoMedia(Int32 id)
    at Umbraco.Web.PublishedCache.ContextualPublishedCache`1.GetById(Boolean preview, Int32 contentId)
    at Umbraco.Web.UmbracoHelper.TypedMedia(Int32 id)
    at ASP._Page_Views_MacroPartials_HomePromoBanners_HomePromoBannersMacro_cshtml.<>c__DisplayClass1.b__0(TextWriter __razor_helper_writer) in d:\WWW<WEBSITEFOLDER>\App\Views\MacroPartials\HomePromoBanners\HomePromoBannersMacro.cshtml:line 36
    at System.Web.WebPages.WebPageBase.Write(HelperResult result)
    at ASP._Page_Views_MacroPartials_HomePromoBanners_HomePromoBannersMacro_cshtml.Execute() in d:\WWW\WWEBSITEFOLDER\App\Views\MacroPartials\HomePromoBanners\HomePromoBannersMacro.cshtml:line 21
    at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
    at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
    at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
    at Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer)
    at Umbraco.Web.Mvc.ControllerExtensions.RenderViewResultAsString(ControllerBase controller, ViewResultBase viewResult)
    at Umbraco.Web.Macros.PartialViewMacroEngine.Execute(MacroModel macro, IPublishedContent content)
    at umbraco.macro.LoadPartialViewMacro(MacroModel macro)
    at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)
    ClientConnectionId:65ac02dd-e359-481f-9d12-ddaf01717e66
    Error Number:102,State:1,Class:15
    

    The lines 21 & eventually 31 has the below call to typed Media: Umbraco.TypedMedia(imageId)

  • Alex Skrypnyk 4847 posts 17440 karma points MVP 2x admin c-trib
    5 days ago
    Alex Skrypnyk
    0

    Hi Nitesh

    Can you show the code of file: ~/Views/MacroPartials/HomePromoBanners/HomePromoBannersMacro.cshtml

    Alex

  • Nitesh 3 posts 73 karma points
    1 day ago
    Nitesh
    0

    Hi Alex,

    Below is the complete code:

    @{
        var languageCode = ContextHelper.GetLanguageCode();
        var currentPage = Model.Content;
        var Banners = currentPage.GetPropertyValue<nuPickers.Picker>("LargePromo").PickedKeys;
        if ( Banners != null && Banners.Any() )
        {
            var oneBanner = Banners.Count() == 1;
    
            <div class="container-fluid">
                <div class="gallery">
                    <div class="slides">
                        @foreach ( var BannerID in Banners )
                        {
                            var Banner = Umbraco.TypedContent(BannerID);
                            if ( Banner != null )
                            {
                                @DisplaySlide(Banner, oneBanner, languageCode)
                            }
                        }
                    </div>
                </div>
            </div>
        }
    
    
    }
    
    @helper DisplaySlide(IPublishedContent Banner, bool oneBanner, string languageCode)
    {
    
    var imageId = Banner.GetPropertyValueAsInt("Image");
    IPublishedContent image = null;
    try
    {
        image = (imageId != null && imageId > 0) ? Umbraco.TypedMedia(imageId) : Umbraco.TypedMedia(DynConfig.Item("Site/DefaultImage/IdNoPhoto"));
    }
    catch (Exception ex)
    {
        Logger.Error(ex);
    }
    
    var color = Banner.GetPropertyValueAsString("textColor");
    var colorClass = "";
    switch ( color )
    {
        case "ffffff":
            colorClass = "white";
            break;
        case "000000":
            colorClass = "black";
            break;
    }
    
    var text = Banner.GetPropertyValueAsString(languageCode + "Text");
    
    var urlMulti = Banner.GetPropertyValue<MultiUrls>(languageCode + "Url");
    var url = "#";
    var target = "_self";
    
    if (urlMulti != null && urlMulti.Any())
    {
        url = urlMulti.FirstOrDefault().Url;
        target = urlMulti.FirstOrDefault().Target;
    }
    
        <div class="slide @colorClass">
            <a href="@url" target="@target" class="slide-link"></a>
            <div class="slide-content">
                <span class="slide-bg"></span>
    
                @if (oneBanner)
                {
                    <picture>
                        <!--[if IE 9]><video style="display: none;"><![endif]-->
                        <source srcset="@image.GetCropUrl(320, 180, quality:100), @image.GetCropUrl(640, 360, quality: 100) 1.5x" media="(max-width: 767px)">
                        <!--[if IE 9]></video><![endif]-->
                        <img class="bg-image" srcset="@image.GetCropUrl(1920, 480, quality: 100)" alt="image">
                    </picture>
                }
                else
                {
                    @GlobalHelpers.DisplayImage(image, 320, 180, 640, 360, 1060, 480, "bg-image")
                }
    
                @if (!String.IsNullOrEmpty(text))
                {
                    <strong class="active-title text-uppercase">@Html.Raw(text)</strong>
                    <strong class="inactive-title text-uppercase">@Html.Raw(text)</strong>
                }
    
            </div>
        </div>
    }
    

    Error happens in below particular code section:

    IPublishedContent image = null;
        try
        {
            image = (imageId != null && imageId > 0) ? Umbraco.TypedMedia(imageId) : Umbraco.TypedMedia(DynConfig.Item("Site/DefaultImage/IdNoPhoto"));
        }
        catch (Exception ex)
        {
            Logger.Error(ex);
        }
    
Please Sign in or register to post replies

Write your reply to:

Draft