Copied to clipboard

Flag this post as spam?

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


  • Nisha patel 5 posts 25 karma points
    Aug 08, 2013 @ 06:58
    Nisha patel
    0

    Content service (of version 6.13) - calling from external Application

    Hello,

    We are using Umbraco CMS in our application. we were using version 4.x and used the web service to fetch the cms content in our applicaiton in MVC. We have just upgraded to version 6.1.3.

    Now while calling any of the methods from Umbraco.Core.Services.ContentService(), we are getting exception as below 

    Incorrect syntax near '`'.   .Net SqlClient Data Provider

    Can you please provide help and guide us for this issue?

    Looking forward to reply.

    Thanks.

  • David Dupont 61 posts 115 karma points
    Aug 08, 2013 @ 10:35
    David Dupont
    0

    Hi Nisha,

    Have a look at the excellent work from Morten : https://github.com/sitereactor/umbraco-console-example

    I manage to get it working by using this marvelous piec of code.

    Regards

  • Nisha patel 5 posts 25 karma points
    Aug 08, 2013 @ 10:41
    Nisha patel
    0

    Hi David,

    Thanks for reply.

    I have gone through this example. But unfortunately it didn't work at my end.

    My applicaiton in MVC, in controller I am getting 'ApplicationContext.Current' always null, so could not follow this example at my end.

    So I am using var service = new Umbraco.Core.Services.ContentService();  but while calling method of content service, I am getting exception.

     

  • David Dupont 61 posts 115 karma points
    Aug 08, 2013 @ 11:23
    David Dupont
    0

    Please provide more elements :

    • Your web.config connection string
    • a more detailed error.
    • Does the console application run when you try the code from Morten ?

     

     

  • Nisha patel 5 posts 25 karma points
    Aug 08, 2013 @ 12:54
    Nisha patel
    0

    connection string in web.config is as below.

    <add name="umbracoDbDSN" connectionString="server=SERVER;Initial Catalog=DBNAME;User Id=USER;Password=PASSWORD" providerName="System.Data.SqlClient" />

    --------------------------------------------

    And Error is as below.

    Incorrect syntax near '`'.

       at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)

       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()

       at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)

       at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()

       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)

       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)

       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 System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)

       at StackExchange.Profiling.Data.ProfiledDbCommand.ExecuteDbDataReader(CommandBehavior behavior)

       at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()

       at Umbraco.Core.Persistence.PetaPocoCommandExtensions.<>c__DisplayClass4.<ExecuteReaderWithRetry>b__3()

       at Umbraco.Core.Persistence.FaultHandling.RetryPolicy.ExecuteAction[TResult](Func`1 func)

       at Umbraco.Core.Persistence.Database.<Query>d__1c`1.MoveNext()

       at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)

       at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)

       at Umbraco.Core.Persistence.Repositories.ContentRepository.PerformGet(Int32 id)

       at Umbraco.Core.Persistence.Repositories.RepositoryBase`2.Get(TId id)

       at Umbraco.Core.Services.ContentService.GetById(Int32 id)

  • David Dupont 61 posts 115 karma points
    Aug 08, 2013 @ 23:03
    David Dupont
    0

    You connection string should contains connection informations to your umbraco database.

    <add name="umbracoDbDSN" connectionString="server=SERVER;Initial 
    Catalog=DBNAME;User Id=USER;Password=PASSWORD" 
    providerName="System.Data.SqlClient" />
  • Nisha patel 5 posts 25 karma points
    Aug 09, 2013 @ 06:11
    Nisha patel
    0

    Yes, Of cource, Original connection string contains server/database/login credentials.  Here SERVER, DBNAME, USER, PASSWORD are replaced only.

  • David Dupont 61 posts 115 karma points
    Aug 09, 2013 @ 08:56
    David Dupont
    0

    Are you able to make the UmbracoConsoleApp to run ?

    If you used source code from the application console to init the umbraco context in your application then try to use :

    ApplicationContext.Current.Services.ContentService
    

    That's the only thing I do in my project.

    If it doesn't work then may be it's a bug introduced in 6.1.3 since my solution runs on Umbraco 6.1.2

    Regards

  • Nisha patel 5 posts 25 karma points
    Aug 09, 2013 @ 13:14
    Nisha patel
    0

    I am not sure whether its version issue or not.

    But I am getting  ApplicationContext.Current always null in my MVC application and its working with console application.

  • David Dupont 61 posts 115 karma points
    Aug 09, 2013 @ 17:12
    David Dupont
    0

    So if consoleApp is working then it's something you forgot to do in your MVC project to initialize the Umbraco context :

    • check the bootstrap part
    • config files (web.config and others in config folder)

    I was able to use Umbraco Services in a LINQPad application by correctly instancing the context and keeping config files.

    It's quite difficult to know what is going bad on your project ... without access to your source hope you will find your answer.

  • David Dupont 61 posts 115 karma points
    Aug 19, 2013 @ 16:16
    David Dupont
    0

    Hi Nisha,

    Did you find what was missing in your MVC project ?

    Regards

  • Tim 4 posts 24 karma points
    Apr 01, 2014 @ 14:28
    Tim
    0

    Hi all,

    Did anyone manage to get this working in an MVC application?

    I have been looking for a solution to this problem for many days now, where by I am trying to get a separate/external MVC to successfully be able to access the umbraco CMS data (assuming by using the ContentService). I have spent alot of time with the console application that was made available and attempted to try and "port" this to an MVC project without any luck. 

    Given the last comments on this were back in August 2013, and Umbraco 7 has now been released. I'm hoping that someone may have some insights into how this might be now possible, and more streamlined. This seems to be a very smart thing to offer and document properly, as in my case having developed many large scale MVC applications, its not ideal to incorporate the CMS into the application itself for a number of reasons. 

    I would very much appreciate any feedback. I am extremely keen to try and find a solution here, as from what I can tell Umbraco is a great product, however this issue is causing us a real block from moving forward with it.

    Thanks in advance!

  • Tim 4 posts 24 karma points
    Apr 01, 2014 @ 14:29
    Tim
    0

    Hi all,

    Did anyone manage to get this working in an MVC application?

    I have been looking for a solution to this problem for many days now, where by I am trying to get a separate/external MVC to successfully be able to access the umbraco CMS data (assuming by using the ContentService). I have spent alot of time with the console application that was made available and attempted to try and "port" this to an MVC project without any luck. 

    Given the last comments on this were back in August 2013, and Umbraco 7 has now been released. I'm hoping that someone may have some insights into how this might be now possible, and more streamlined. This seems to be a very smart thing to offer and document properly, as in my case having developed many large scale MVC applications, its not ideal to incorporate the CMS into the application itself for a number of reasons. 

    I would very much appreciate any feedback. I am extremely keen to try and find a solution here, as from what I can tell Umbraco is a great product, however this issue is causing us a real block from moving forward with it.

    Thanks in advance!

  • Tim 4 posts 24 karma points
    Apr 01, 2014 @ 14:36
    Tim
    0

    Is Umbraco web services potentially the answer?

Please Sign in or register to post replies

Write your reply to:

Draft