Answer the question
In order to leave comments, you need to log in
Why is the same copy of data inserted into the database?
I can't understand why the following code inserts the same copy of the data into the database.
This is how it looks.
The method accepts an array of data from the PG. Then it runs through it and inserts each element into SQLite. I even added the output of the elements. All different ones are output, but the same one is inserted stubbornly. Here is my code:
public void InsertData(List<UserData> PGuds)
{
Connection = new SQLiteConnection("Data Source=" + config.SQLLitePath + ";Version=3;");
Connection.Open();
SQLiteCommand insertSQL = new SQLiteCommand(@"INSERT INTO ""USERS"" (id, guid, username, userblob) VALUES (?,?,?,?)", (SQLiteConnection)Connection);
try
{
Console.WriteLine(uds.Count);
Console.WriteLine("iiiiiiiiiiiiiiiiiiiiii");
foreach (UserData d in PGuds)
{
Console.WriteLine("ooooooooooooo");
Console.WriteLine(d.Id);
Console.WriteLine(d.Guid);
Console.WriteLine(d.Name);
insertSQL.Parameters.Add(new SQLiteParameter { Value = d.Id });
insertSQL.Parameters.Add(new SQLiteParameter { Value = d.Guid });
insertSQL.Parameters.Add(new SQLiteParameter { Value = d.Name });
insertSQL.Parameters.Add(new SQLiteParameter { Value = d.UserBlob, DbType = DbType.Binary });
insertSQL.ExecuteNonQuery();
Console.WriteLine("Data Inserted in SQLLite");
}
}
catch (Exception e)
{
Console.WriteLine(e.StackTrace);
Console.WriteLine(e.Message);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question