I create a structure. Then I fill it with creation and I want to transfer each element of this structure to another method and there already (in another DB) perform data insertion. Here is the code:
void selectDataForSync() //data from PG that whould be insert in SQLLITE { UserData ud; List<UserData> uds = new List<UserData>(); NpgsqlConnection conn = new NpgsqlConnection("Server=127.0.0.1;Port=5432;User Id=" + config.PGLogin + ";" + "Password=" + config.PGPass + ";"); conn.Open(); string SQLrequest = @"SELECT guid, username, ""FL"", id, userblob FROM ""USERS"" WHERE ""FL""=10;"; NpgsqlCommand command = new NpgsqlCommand(SQLrequest, conn); try { NpgsqlDataReader dr = command.ExecuteReader(); // here exception while (dr.Read()) { // UserData ud = new UserData(); ud.id = Int32.Parse(dr[0].ToString()); ud.guid = (dr[1].ToString()); ud.name = (dr[2].ToString()); ud.userblob = (byte[])dr[3]; // uds.Add(ud); sqllite.insertDataFromPGToSQLLite(ud); } dr.Dispose(); // releases conenction } catch (Exception e) { Console.WriteLine(e.Message); } finally { conn.Close(); } } Persistently swears at the line: sqllite.insertDataFromPGToSQLLite(ud); Mol: argument type is not assignable to parameter type
The definition of the structure itself looks like this
On the SQLLite side, the code is:
public struct UserData { public int id; public string guid; public string name; public byte[] userblob; }; public void insertDataFromPGToSQLLite(UserData ud) { }
DBSync.DB.SQLLite.UserData ud;- IgorUserData ud;declared typesqllite.insertDataFromPGToSQLLite(ud);I transferred the data to the structure in the SQLLite part added the same as here. Look at the post, I updated it. - Dmitry BubnenkovUserDatatypeUserDatadefined in two places:DBSync.PostgresandDBSync.DB.SQLLite. You declared a variable of typeDBSync.Postgres.UserData, and thesqllite.insertDataFromPGToSQLLitemethod needsDBSync.DB.SQLLite.UserData. - Igor