Need Help


I can't add infromation to my Projet.mdb ! please help me ! this is my code



```
Try


            Dim ConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source =  C:\projet.mdb"

            Dim Save As New OleDbCommand
            Dim Conn As New OleDbConnection(ConStr)

            Save.CommandText = "INSERT INTO Client(Nom,Prenom,Adresse,Téléphone,date) VALUES(@p1,@p2,@p3,@p4,@p5)"
            Save.Parameters.AddWithValue("@p1", TextBox1.Text)
            Save.Parameters.AddWithValue("@p2", TextBox2.Text)
            Save.Parameters.AddWithValue("@p3", TextBox3.Text)
            Save.Parameters.AddWithValue("@p4", TextBox4.Text)
            Save.Parameters.AddWithValue("@p5", DateTimePicker1.Text)
            Save.Connection = Conn
            Conn.Open()
            Save.ExecuteNonQuery()
            MsgBox("Ajout réussi ")
            frm1.Show()
        Catch ex As Exception
            Exit Sub
        End Try

```
Have you tried putting all of your connection items and actions before you do the parameters?
<http://code.djangoproject.com/wiki/CookBookNewformsAdminAndUser>


Involves implementing save methods on your ModelAdmin objects. There is not an existing script but you could probably do it thru the Lotus COM interface. The easiest way is to create an agent in Lotus Notes to extract the information from Excel, and then using the NOTESACL objects of NotesDatabase add the references.


Does this help? If you need further assistance, please be a little more descriptive and I will see if I can help further.


Mike K. You could go the easy way and use [ADO.NET Data Services](http://codebetter.com/blogs/david.hayden/archive/2008/01/08/getting-started-with-ado-net-data-services.aspx). You can call `context.Database.Migrate()`in your `Startup.cs`


eg:



```
using (var context = new MyContext(...))
{
    context.Database.Migrate();
}

``` someone forgot to link one of the answers in the meantime.

[image]

[how can i run run occ db:add-missing-indices on shared hosting](https://help.nextcloud.com/t/how-can-i-run-run-occ-db-add-missing-indices-on-shared-hosting/36761/2) [support](/c/support)

i found a work around for this, so if anyone else finds themselves in the same boat, this is one way to resolve it.

i don’t have shel… need to add 



```
services.AddEntityFrameworkSqlite().AddDbContext<ApplicationDbContext>();

```

and delete



```
services.AddIdentity<IdentityUser, IdentityRole>()
                    .AddEntityFrameworkStores<ProductContext>();

```

in startup.
the error was about bad startup configuration.
Was sending too much things.


ApplicationDbContext:



```
 public class ApplicationDbContext : IdentityDbContext
    {
        public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
            : base(options)
        {
        }
        public Microsoft.EntityFrameworkCore.DbSet<Product> Products { get; set; }
        public Microsoft.EntityFrameworkCore.DbSet<List> Lists { get; set; }

        public Microsoft.EntityFrameworkCore.DbSet<ProductList> ProductLists { get; set; }


        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            base.OnConfiguring(optionsBuilder);

             optionsBuilder.UseSqlite("Data Source=assistant.db");

        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {

            base.OnModelCreating(modelBuilder);
            modelBuilder.Entity<ProductList>()
                .HasKey(pl => new { pl.ProductId, pl.ListId });

            modelBuilder.Entity<ProductList>()
                .HasOne(pl => pl.Product)
                .WithMany(p => p.ProductList)
                .HasForeignKey(pl => pl.ProductId)
                .OnDelete(DeleteBehavior.Cascade);

            modelBuilder.Entity<ProductList>()
                .HasOne(pl => pl.List)
                .WithMany(l => l.ProductList)
                .HasForeignKey(pl => pl.ListId)
                .OnDelete(DeleteBehavior.Cascade);
        }
    }

``` [image] andrei:

a quick fix is to comment the line in the "on message" tab for the function node that is troubled

when you add a module in "setup", the "import as" name is made available to the function tabs...

[image]

... so you dont need to declare it nor do you need to set/get it from co… hi chris, 
if you use relations api, you may set properties field in your query. in this field you should set the names of the properties which values must be retrieved from the server. the argument should be a string in the following format: "propertyname1, propertyname2, , , propertynamen" , wher… Not sure about `ThenInclude()` and EF 7, but you can do something like this in your repositories (tested with EF 6):



```
public MyEntity GetMyEntity_EagerlyLoad(DbContext context, int id, params Expression<Func<MyEntity, object>>[] propertiesToLoad)
{
    var q = context.MyEntities.Where(m => m.ID == id);

    foreach (var prop in propertiesToLoad)
        q = q.Include(prop);

    return q.SingleOrDefault();
}

```

You can then call it like this:



```
repo.GetMyEntity_EagerlyLoad(context, id, m => m.Property1, m => m.Property2, m => m.Property1.NestedProperty)

```

  



**EDIT**: There is also the alternative way to do eager loading with EF using projection. You could do a generic repository method like this:



```
public MyEntity GetMyEntity_EagerlyLoad<T>(DbContext context, int id, Expression<Func<MyEntity, T>> loadingProjection, Func<T, MyEntity> resultProjection)
{
    var q = context.MyEntities.Where(m => m.ID == id);

    return q.Select(loadingProjection).AsEnumerable().Select(resultProjection).SingleOrDefault();
}

```

And then call it with the properties you want loaded and the entity you want the method to return:



```
repo.GetMyEntity_EagerlyLoad(context, id, m => new { myEntity = m, m.Property1, m.Property2, m.Property1.NestedProperty }, m => m.myEntity)

``` A few things to try.


1. Use [Variable Tables](http://odetocode.com/Articles/365.aspx) instead -> maybe the import wizard prefers that?
2. Name your return fields.


Try using the following stored proc (untested .. just thinking out loud...)



```
CREATE PROCEDURE dbo.Foo
AS

    SET NOCOUNT ON

    DECLARE @ResultTable TABLE (SomeId INTEGER)

    INSERT INTO @ResultTable
    SELECT DISTINCT Id AS Identity -- Or u can rename this field to anything...
    FROM SomeExistingTableWhichHasAnIdentityField

GO

```

Try that and see if the wizard refreshes, now.


-- 


 Attempt #2 :)


Ok .. when the EF designer/wizard/whatever fails to figure out EXACTLY what my stored proc is suppose to be returning, I usually do the following :-


1. Make sure the stored procedure doesn't exist at all in the EF designer/context, etc. (You have a clean starting point)
2. Open up your stored procedure and `/* /*` comment out *EVERYTHING* after the procedure definition.


eg..



```
ALTER PROCEDURE dbo.Foo
(
    Bar1 INT,
    Bar2 TINYINT,
    ... // whatever u have as your optional input arguments //
)
AS
    SET NOCOUNT ON

    /* 
    .... every thing in here is commented out 
    */
GO

```

Now ...
 3. Add a forced fake return in the stored proc, which (more or less) just *defines* the output structure/fields.


eg..



```
ALTER PROCEDURE dbo.Foo
(
    Bar1 INT,
    Bar2 TINYINT,
    ... // whatever u have as your optional input arguments //
)
AS
    SET NOCOUNT ON

    SELECT 1 AS Id, 1 AS UserId, 1 AS SomeOtherId, 
        CAST('AAA' AS NVARCHAR(350)) AS Name,
        -- etc etc etc..
    /* 
    .... every thing in here is commented out 
    */
GO

```

[and then](http://www.youtube.com/watch?v=K7luMp6lb9M) ...


4. Add this stored proc to your EF designer/wizard/etc... Now the correct fields should be 'determined' by the designer. AWESOME. Yes .. the values are all hardcoded .. but that's ok (so far).
5. Once your happy that EF is now updated right, go back to your stored proc, and remove all hardcoded SELECT (which we did in the above step). Now we remove the comments which we commented out the entire real code. So you should have your original stored proc, back.


... and now EF is updated and doesn't know we've changed the plumbing of your stored proc.


win :)


does this work for ya?