Copied to clipboard

Flag this post as spam?

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


  • teus 42 posts 74 karma points
    Sep 29, 2010 @ 11:58
    teus
    0

    Using sql Prevalue source in datasource linked form

    Say I have a database table called Animal wher the column fkSpecies is a foriegn key of the the table species.

    I want to constuct a form which stores the data in the Animal table and contains a dropdown list of all species.

    I made a Prevalue Source called PVSpecies. But when I try to make a form based on the datasource to table Animal , I cannot choose the PVSpecies. When I choose the dropdownlist(or radiobuttonlist) fieldtype for the column fkSpecies I get a "Object reference not set to an instance of an object" error (see below)

    My question: Is It possible to use a sql Prevalue source in a datasource linked form? 

     

     

     

    Server Error in '/' Application.

    Object reference not set to an instance of an object.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:


    Stack Trace:

    [NullReferenceException: Object reference not set to an instance of an object.]
       System.Object.GetType() +0
       Umbraco.Forms.UI.Usercontrols.EditForm.GetPrevalueAttributes(Field f) in d:\TeamCity\buildAgent\work\e4473b9ec9597356\Umbraco.Forms.UI\Usercontrols\EditForm.ascx.cs:226
       ASP.usercontrols_umbracocontour_editform_ascx.__DataBind__control9(Object sender, EventArgs e) +1627
       System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +304
       System.Web.UI.Control.DataBindChildren() +11252903
       System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +321
       System.Web.UI.WebControls.Repeater.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem) +185
       System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource) +643
       System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e) +167
       Umbraco.Forms.UI.Usercontrols.EditForm.RenderFieldset(Object sender, RepeaterItemEventArgs e) in d:\TeamCity\buildAgent\work\e4473b9ec9597356\Umbraco.Forms.UI\Usercontrols\EditForm.ascx.cs:157
       System.Web.UI.WebControls.Repeater.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem) +204
       System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource) +643
       System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e) +167
       Umbraco.Forms.UI.Usercontrols.EditForm.RenderPage(Object sender, RepeaterItemEventArgs e) in d:\TeamCity\buildAgent\work\e4473b9ec9597356\Umbraco.Forms.UI\Usercontrols\EditForm.ascx.cs:145
       System.Web.UI.WebControls.Repeater.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem) +204
       System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource) +643
       System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e) +167
       Umbraco.Forms.UI.Usercontrols.EditForm.Page_Load(Object sender, EventArgs e) in d:\TeamCity\buildAgent\work\e4473b9ec9597356\Umbraco.Forms.UI\Usercontrols\EditForm.ascx.cs:59
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
       System.Web.UI.Control.LoadRecursive() +71
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3048
    


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1              

     

  • Comment author was deleted

    Sep 30, 2010 @ 09:06

    Hi Tues, I'll have to check but you might have discovered a bug.

    However if you use a datasource to generate a form based on your Animal table it should work fine

  • teus 42 posts 74 karma points
    Sep 30, 2010 @ 11:40
    teus
    0

    Indeed, it worked fine when I added the foreign key constraint between Animal and Species. My bad ;-) Then I got the extra form where I could Setup the foreign keys.

    After that a form to set up the fieldtypes where I could choose the Dropdownlist. It all works now.

    Nevertheless, the above error remains ofcourse.  And I found another one if you forget to choose a column when setting up the foreign key(s). See below.

    A feature request would be if the datasourceform process could be made more flexible; sometimes I forget to add a column when making the form and then I have to start over again.

    But Contour is great! It saves me a lot of time!

     

     

    Server Error in '/' Application.

    Incorrect syntax near the keyword 'ASC'.
    An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Add a name or single space as the alias name.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.OleDb.OleDbException: Incorrect syntax near the keyword 'ASC'.
    An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Add a name or single space as the alias name.

    Source Error:

    The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:

    1. Add a "Debug=true" directive at the top of the file that generated the error. Example:

      <%@ Page Language="C#" Debug="true" %>

    or:

    2) Add the following section to the configuration file of your application:

    <configuration>
       <system.web>
           <compilation debug="true"/>
       </system.web>
    </configuration>

    Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.

    Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.


    Stack Trace:

    [OleDbException (0x80040e14): Incorrect syntax near the keyword 'ASC'.
    An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Add a name or single space as the alias name. ]
       System.Data.OleDb.OleDbDataReader.ProcessResults(OleDbHResult hr) +60
       System.Data.OleDb.OleDbDataReader.NextResult() +646
       System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +546
       System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) +281
       Umbraco.Forms.Core.Providers.DatasourceTypes.MsSql.GetPrevalues(Field field) in d:\TeamCity\buildAgent\work\e4473b9ec9597356\Umbraco.Forms.Core\Providers\DatasourceTypes\MsSql.cs:217
       Umbraco.Forms.Core.Providers.Prevalues.Standard.GetPreValues(Field field) in d:\TeamCity\buildAgent\work\e4473b9ec9597356\Umbraco.Forms.Core\Providers\Prevalues\Standard.cs:46
       Umbraco.Forms.UI.Usercontrols.EditForm.RenderFieldPreview(Field f) in d:\TeamCity\buildAgent\work\e4473b9ec9597356\Umbraco.Forms.UI\Usercontrols\EditForm.ascx.cs:205
       ASP.usercontrols_umbracocontour_editform_ascx.__DataBind__control18(Object sender, EventArgs e) +139
       System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +304
       System.Web.UI.Control.DataBindChildren() +11252903
       System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +321
       System.Web.UI.WebControls.Repeater.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem) +185
       System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource) +643
       System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e) +167
       Umbraco.Forms.UI.Usercontrols.EditForm.RenderFieldset(Object sender, RepeaterItemEventArgs e) in d:\TeamCity\buildAgent\work\e4473b9ec9597356\Umbraco.Forms.UI\Usercontrols\EditForm.ascx.cs:157
       System.Web.UI.WebControls.Repeater.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem) +204
       System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource) +643
       System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e) +167
       Umbraco.Forms.UI.Usercontrols.EditForm.RenderPage(Object sender, RepeaterItemEventArgs e) in d:\TeamCity\buildAgent\work\e4473b9ec9597356\Umbraco.Forms.UI\Usercontrols\EditForm.ascx.cs:145
       System.Web.UI.WebControls.Repeater.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem) +204
       System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource) +643
       System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e) +167
       Umbraco.Forms.UI.Usercontrols.EditForm.Page_Load(Object sender, EventArgs e) in d:\TeamCity\buildAgent\work\e4473b9ec9597356\Umbraco.Forms.UI\Usercontrols\EditForm.ascx.cs:59
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
       System.Web.UI.Control.LoadRecursive() +71
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3048
    



    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

  • Comment author was deleted

    Sep 30, 2010 @ 12:07

    Thanks for the feedback! I'll add this to our issue tracker and we'll take a look at the issues.

  • jaygreasley 416 posts 403 karma points
    Oct 04, 2010 @ 09:52
    jaygreasley
    0

    I may have a similar issue.

    I have 2 tables, Customers and Countries. Customers has a foreigh key on it's CountryID to the Countries table.

    When I create a form based on Customers I can't seem to pull in CountryName from the Countries.It does offer me the CountryID though.

    I can create an empty form and use the Countries prevalue though.

    tia

    Jay

  • Comment author was deleted

    Oct 04, 2010 @ 10:02

    Hmm that's strange, so you are creating a datasource and then creating a form based on that, is your foreign key constraint setup ?

  • jaygreasley 416 posts 403 karma points
    Oct 04, 2010 @ 10:05
    jaygreasley
    0

    That is what I am doing. Although I added the foreign key constraint after I created the datasource, could that be it?

  • Comment author was deleted

    Oct 04, 2010 @ 10:08

    Might be but I doubt it, try creating a new datasource

  • jaygreasley 416 posts 403 karma points
    Oct 04, 2010 @ 10:08
    jaygreasley
    0

    That was it, I created a new datasource and then when I create a form I get the extra page to select the value field.

    Cheers

    Jay

Please Sign in or register to post replies

Write your reply to:

Draft