The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

esDataSource Insert fails

Last post 08-14-2008, 4:54 AM by Mike.Griffin. 3 replies.
Sort Posts: Previous Next
  •  08-13-2008, 4:36 AM 10715

    esDataSource Insert fails

    I'm trying to insert records using the esDataSource and a DetailsView which is nested within a Gridview.

    The DetailsView only shows a single textbox and a commandbutton (insert). I've trapped the esDataSource_esPreInsert() event to add the rest of the values like so (values contain good values, just changed for readability):

    Code:
    Private Sub esDataSource1_esPreInsert(ByVal sender As Object, ByVal e As EntitySpaces.Web.esDataSourceInsertEventArgs) Handles esDataSource1.esPreInsert
            
            e.Values("SiNumber") = value1
            e.Values("PnmMain") = value2
            e.Values("PnmAutoKey") = value3
            e.Values("InspectionType") = value4
            e.Values("Description") = value5
    
    End Sub
    However while inserting I get a nasty Oracle error message saying the Values keyword is missing. I'm guessing my approach to set values is not the right one?
  •  08-13-2008, 5:02 AM 10718 in reply to 10715

    Re: esDataSource Insert fails

    You should only have to implement esCreateEntity

     

    Code:
    protected void EsDataSource1_esCreateEntity(object sender, EntitySpaces.Web.esDataSourceCreateEntityEventArgs e)
    {
    	Employees entity = new Employees();
    
    	if (e.PrimaryKeys != null)
    	{
    		entity.LoadByPrimaryKey((int)e.PrimaryKeys[0]);
    	}
    
    	// Assign the Entity
    	e.Entity = entity;
    }
    
     

     


    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  08-14-2008, 1:17 AM 10738 in reply to 10718

    Re: esDataSource Insert fails

    Yes I had already done this.

    The problem is that my DetailsView should only have one field (partnumber). The other fields should not be entered by the user, these are retrieved by the system. These fields cannot be Null when inserting, so I need to fill them manually before the insert is performed... any suggestions?

  •  08-14-2008, 4:54 AM 10745 in reply to 10738

    Re: esDataSource Insert fails

    Yes, on your esDataSourceInsertEventArgs in your PreInsert method you will find your entity, go ahead and set fields:

    e.Entity.SomeField = "data";

    See the documentation on the esDataSourceInsertEventArg class. The esDataSource always hands you your entity on the events.


    EntitySpaces | Twitter | BLOG | Please honor our Software License
View as RSS news feed in XML