Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

C # SQL; Overwrite the deleted data record

In an existing SQL database, I delete a data record with using (var connection = new SQLiteConnection (System.IO.Path.Combine (folder, dbName)))
{
connection.Delete (prices);
}
It works fine. Then a new data record is written to the DB. The new data record now has a new ID after it has been saved. The ID is the PrimaryKey. At first the data sets were marked with the ID 1,2,3,4 etc. After deleting data record 2 and adding a new data record, it is now 1,3,4,5. How is it possible to write the new data record in the line of the deleted data record 2 after saving and how does it get ID 2? Thanks for an answer.

Best Answers

Answers

  • jezhjezh Member, Xamarin Team Xamurai

    How is it possible to write the new data record in the line of the deleted data record 2 after saving and how does it get ID 2?

    Why not update the second item if you want to override the original data?

  • Peter62Peter62 Member ✭✭

    Update works fine. But I also made it possible to delete data with Delete. If the user now wants to enter new data, a new data record with a new ID is created. The ID of the deleted record remains empty. I don't want that. Hence the idea that the free space should be overwritten with the new data record. Data is saved with:

    public void Save(Prices cPrices)
    {
    var newData = new Prices();

            if (newData.Id == 0)
            {
                using (var connection = new SQLiteConnection (System.IO.Path.Combine (folder, dbName)))
                {
                    connection.Insert (cPrices);
                }
            }
            else
            {
                using (var connection = new SQLiteConnection (System.IO.Path.Combine (folder, dbName)))
                {
                    connection.Update (cPrices);
                }
            }
    

    }

    Please also answer the following question for me:
    Now that my project is ready to be deployed, I get the following error message:
    Severity Code Description Project File Line Suppression State
    Warning MSB3277: Conflicts between different versions of Microsoft.CSharp were found that could not be resolved. These referral conflicts are listed in the build log when the Log Verbosity is set to Verbose. 0

    It is therefore unfortunately not possible to deploy the project here.

    Please can you help me here too. Thank you.

  • jezhjezh Member, Xamarin Team Xamurai

    Severity Code Description Project File Line Suppression State
    Warning MSB3277: Conflicts between different versions of Microsoft.CSharp were found that could not be resolved. These referral conflicts are listed in the build log when the Log Verbosity is set to Verbose. 0

    For this issue, you can try to turn MSBuild output log to Diagnostic (Tools->Options->Project and Solutions->Build and Run, set MSBuild project build output verbosity), and then post the output log here.

  • Peter62Peter62 Member ✭✭
    edited October 27

    I finally managed to output the protocol. The error message relates line 2084 ! I have included this output from line 2075 to 2140 below. I hope it will help us.

    here is line Nr 2075

    Normally, as an optimization, finding dependencies of references marked with ExternallyResolved=true metadata is skipped.
    However, skipping that step breaks binding redirect generation when there are conflicting versions within the externally
    resolved graph.
    -->

    false
    true

    here ist line Nr 2082

    here ist line 2084

      <Output TaskParameter="ResolvedFiles" ItemName="ReferencePath"/>
      <Output TaskParameter="ResolvedFiles" ItemName="_ResolveAssemblyReferenceResolvedFiles"/>
      <Output TaskParameter="ResolvedDependencyFiles" ItemName="ReferenceDependencyPaths"/>
      <Output TaskParameter="RelatedFiles" ItemName="_ReferenceRelatedPaths"/>
      <Output TaskParameter="SatelliteFiles" ItemName="ReferenceSatellitePaths"/>
      <Output TaskParameter="SerializationAssemblyFiles" ItemName="_ReferenceSerializationAssemblyPaths"/>
      <Output TaskParameter="ScatterFiles" ItemName="_ReferenceScatterPaths"/>
      <Output TaskParameter="CopyLocalFiles" ItemName="ReferenceCopyLocalPaths"/>
      <Output TaskParameter="SuggestedRedirects" ItemName="SuggestedBindingRedirects"/>
      <Output TaskParameter="FilesWritten" ItemName="FileWrites"/>
      <Output TaskParameter="DependsOnSystemRuntime" PropertyName="DependsOnSystemRuntime"/>
      <Output TaskParameter="DependsOnNETStandard" PropertyName="_DependsOnNETStandard"/>
    </ResolveAssemblyReference>
    

  • Peter62Peter62 Member ✭✭

    I will send you the entire log about the error message. I hope you can help me with this. Thank you.

  • Peter62Peter62 Member ✭✭
    edited October 28

    The attached error.txt file relates to the error. The error message relates line 2084. The whole log is in error 2.txt. Can you see it and open it?

  • Peter62Peter62 Member ✭✭

    Hello! I want to thank you for the tips. The error was found. A Microsoft.EntityFrameworkCore was installed in the NuGet package. That caused the message. Everything was fine after deinstallation. Thanks for your help. Regards Peter

Sign In or Register to comment.