umbraco / Umbraco.Forms.Issues

Public issue tracker for Umbraco Forms
29 stars 0 forks source link

formService.Get(id) Sql Error #411

Closed filefontaine closed 3 years ago

filefontaine commented 4 years ago

If the option StoreUmbracoFormsInDb is set to false, the formService.Get(id) as a Sql Error.

System.Data.SqlClient.SqlException (0x80131904): Invalid object name 'UFForms'.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 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, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
   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 System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
   at StackExchange.Profiling.Data.ProfiledDbCommand.ExecuteDbDataReader(CommandBehavior behavior) in C:\projects\dotnet\src\MiniProfiler.Shared\Data\ProfiledDbCommand.cs:line 208
   at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
   at Umbraco.Core.Persistence.FaultHandling.FaultHandlingDbCommand.<>c__DisplayClass30_0.<ExecuteDbDataReader>b__0() in D:\a\1\s\src\Umbraco.Core\Persistence\FaultHandling\RetryDbConnection.cs:line 204
   at Umbraco.Core.Persistence.FaultHandling.FaultHandlingDbCommand.<>c__DisplayClass33_0`1.<Execute>b__0() in D:\a\1\s\src\Umbraco.Core\Persistence\FaultHandling\RetryDbConnection.cs:line 222
   at Umbraco.Core.Persistence.FaultHandling.RetryPolicy.ExecuteAction[TResult](Func`1 func) in D:\a\1\s\src\Umbraco.Core\Persistence\FaultHandling\RetryPolicy.cs:line 172
   at Umbraco.Core.Persistence.FaultHandling.FaultHandlingDbCommand.Execute[T](Func`1 f) in D:\a\1\s\src\Umbraco.Core\Persistence\FaultHandling\RetryDbConnection.cs:line 219
   at Umbraco.Core.Persistence.FaultHandling.FaultHandlingDbCommand.ExecuteDbDataReader(CommandBehavior behavior) in D:\a\1\s\src\Umbraco.Core\Persistence\FaultHandling\RetryDbConnection.cs:line 204
   at System.Data.Common.DbCommand.ExecuteReader()
   at NPoco.Database.ExecuteReaderHelper(DbCommand cmd)
   at NPoco.Database.ExecuteDataReader(DbCommand cmd)
   at NPoco.Database.<QueryImp>d__164`1.MoveNext()
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at NPoco.Database.FirstOrDefault[T](Sql sql)
   at Umbraco.Forms.Core.Persistence.Repositories.Implement.FormRepository.PerformGet(Guid id)
   at Umbraco.Core.Cache.NoCacheRepositoryCachePolicy`2.Get(TId id, Func`2 performGet, Func`2 performGetAll) in D:\a\1\s\src\Umbraco.Core\Cache\NoCacheRepositoryCachePolicy.cs:line 17
ClientConnectionId:XXX
Error Number:208,State:1,Class:16

For get the form we need to do : formStorage.GetForm(GUID)

But is set as Obselete.

Have you another solution or the best is to set up StoreUmbracoFormsInDb as True


_This item has been added to our backlog AB#8726_

nul800sebastiaan commented 4 years ago

I am not sure why the GUID version would be obsolete, that's definitely the one we should prefer! I'll have to have a look, please keep using formStorage.GetForm(GUID).

nul800sebastiaan commented 4 years ago

Alright I had a look, formService.Get(id) goes straight to the database, it looks like we don't check if StoreUmbracoFormsInDb is true or false, we'll have to fix that up.

nul800sebastiaan commented 4 years ago

For now, using formStorage.GetForm(GUID) is recommended for you.

OnlinePseudonym commented 4 years ago

@nul800sebastiaan I'm still getting that error when using formService.GetForm(GUID) in 8.5.3. I had to downgrade to 8.4.2

filefontaine commented 4 years ago

Hello @OnlinePseudonym ,

If you haven't set the parameter StoreUmbracoFormsInDb as True in UmbracoFroms.config you need to use formStorage.GetForm(GUID); not the formService.GetForm(GUID) the class for the formStorage is IFormStorage.

You can get it with :

using Umbraco.Forms.Core.Data.Storage;
var formStorage = Current.Factory.GetInstance<IFormStorage>();
filefontaine commented 4 years ago

@nul800sebastiaan Thanks for all, i will do that.

OnlinePseudonym commented 4 years ago

@filefontaine ahhh! Thanks, my brain just glossed over the class name difference! I even had to read over your comment twice to see it.

afinn-tech commented 3 years ago

Is this still an issue in 8.5.5 , @nul800sebastiaan Data.SqlClient.SqlException (0x80131904): Invalid object name 'UFForms'. i keep getting this error , on rebuild of the Forms index Index populating failed for populator "Umbraco.Forms.Core.Data.RecordIndex.FormsIndexPopulator" ?\ Formsconfig , is set to false . (fyi)

nul800sebastiaan commented 3 years ago

For now you can ignore it, it's not harmful.

warrenbuckley commented 3 years ago

This will be due in the next version of Forms

ccampbell-nra commented 3 years ago

I know this issue is marked "closed" but I'm building an Umbraco CMS 8.14.0 site with UForms 8.7.4 and I'm still seeing the issue. The config key "StoreUmbracoFormsInDb" is marked "False". I have a workflow helper class where I'm being directed to use:

Form form = _formService.Get(record.Form);

But that's throwing a SqlException.

AndyButland commented 3 years ago

You need to be using IFormStorage when working with forms stored on disk. IFormService is a newer service that expects the forms in the database. IFormStorage is marked as obsolete - it's been removed in V9 - but it'll be available for any subsequent releases of Umbraco Forms V8.

MalikFarhanManzoor commented 7 months ago

@Umbraco.RenderMacro("renderUmbracoForm". i am using RenderMarco still i am getting this error I am not using any Controller and using 8.18.9 version