Crainiate Community

Support and discussion for users of Crainiate component software products
Welcome to Crainiate Community Sign in | Join | Help
in Search

Trying out your product, errors with first sample program

Last post 08-27-2007 5:54 PM by Bighugedave. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 08-23-2007 2:39 PM

    Trying out your product, errors with first sample program

    Hello,


    I'm trying out the very first sample program in VS.Net 2005 from you help .chm file.  I get the program to create the "Person" table for me, via this code:

     //Create a database connection
            SqlContext context = new SqlContext();
            context.Server = "TRY-20-3228";
            context.Database = "Objecto";
            context.Prefix = "Crainiate.Data.Persistence.Examples";
            context.UserId = "ObjectoUser";
            context.Password = "test";

            //Deploy changes to the database
            SqlDeployment deployment = new SqlDeployment();
            deployment.Context = context;
            deployment.DeploymentType = Crainiate.Data.Persistence.Providers.DeploymentType.Deploy;
            deployment.Deploy(System.Reflection.Assembly.GetAssembly(typeof(Crainiate.Data.Persistence.Examples.Person)));

     

    However, when the code runs to insert a Person, just copy and pasted from your help file, it gives me the error:

    The requested database was not found. Use the SqlDeployment class to create a database if required.

    The code that causes this is the following:

    //Create a command to execute object data requests
            Command command = context.CreateCommand();

            //Insert a new person object
            Person person = new Person();
            person.FirstNames = "John";
            person.LastNames = "Smith";
            person.DateOfBirth = new DateTime(1974, 4, 23);

            person.Command = command;
            person.Insert();

    It fails at the person.Insert() method.  I've gone over this many times and I have no idea what's going on.  It creates the Person table, but then can't find the database?

    Thanks for any help you can provide.  Our company is trying to decide on an ORM package to use.

     
    Kind regards,

    David
     

    • 63.68.228.197
  • 08-23-2007 6:25 PM In reply to

    Re: Trying out your product, errors with first sample program

    Hi David,

    This can be caused if your user 'ObjectoUser' doesnt have adequate permissions to read the master database.

    In a query window using the same permissions, try the following sql:

    select * FROM sys.master_files m

    If this returns an error you need to add read permission to the master database for the user.

    Alternatively, you can validate the context by setting the valid flag through reflection:

    System.Reflection.MethodInfo method = typeof(SqlContext).GetMethod("SetValid", BindingFlags.Instance | BindingFlags.NonPublic);
    method.Invoke(context,
    new object[] { true });

     Call that code once you have configured your context to bypass the database checking mechanism. This will be addressed in the next build.

     

     

    • 81.156.197.178
  • 08-23-2007 8:50 PM In reply to

    Re: Trying out your product, errors with first sample program

    Thank you very much James, much appreciated!

     David
     

    • 63.68.228.197
  • 08-24-2007 12:59 PM In reply to

    Re: Trying out your product, errors with first sample program

    Well, I gave the test user account access to the master database, and I ran the query you mentioned

    select * FROM sys.master_files m

    and that query returned results just fine using the same account I'm using in the code.

     But it's still giving me the same error, that it cannot find the database, even though it could previously because it creates the table in the database just fine.

    Regards,

    David
     

    • 63.68.228.197
  • 08-27-2007 1:39 PM In reply to

    Re: Trying out your product, errors with first sample program

    A possible problem has been found and a fix has been made. The latest installshield can be downloaded from the following link

    Objecto Framework 1.1.2795

    If you prefer to update your project and the GAC directly, the assembly .dll file can be downloaded here:

    Crainiate.Data.Persistence.1.1.2795.zip

    Please let us know if this resolves your issue, and if we can help in any further way

    • 81.156.127.190
  • 08-27-2007 5:54 PM In reply to

    Re: Trying out your product, errors with first sample program

     Thank you James for your help! Big Smile

     One of our developers actually figured out the problem, he changed the sample code, for the persisted class, where it has  private Nullable<DateTime> _dateOfBirth;

    and he took the Nullable off, and it worked fine after that.

     Regards,

    David
     


     

    • 63.68.228.197
Page 1 of 1 (6 items)