I have a structure declared in a separate file. I need to fill it with data from one database and insert it into another, but the error with the types persists. I suspect that the syntax of the request with the parameters is not true.
string SQLrequest = @"SELECT id, guid, username, userblob FROM ""USERS"""; NpgsqlCommand command = new NpgsqlCommand(SQLrequest, conn); try { NpgsqlDataReader dr = command.ExecuteReader(); // here exception while (dr.Read()) { // UserData ud = new UserData(); ud.id = dr[0].ToString(); ud.guid = (dr[1].ToString()); ud.name = (dr[2].ToString()); ud.userblob = (byte[]) dr[3]; } dr.Dispose(); // releases conenction } It seems to be true, or am I mistaken about something?
public void insertDataFromPGToSQLLite(UserData ud) { SQLiteConnection m_dbConnection = new SQLiteConnection("Data Source=" + config.SQLLitePath + ";Version=3;"); m_dbConnection.Open(); SQLiteCommand insertSQL = new SQLiteCommand("INSERT INTO test01.USERS id, guid, name, userblob) VALUES (?,?,?,?)", m_dbConnection); try { insertSQL.Parameters.Add(ud.id); insertSQL.Parameters.Add(ud.guid); insertSQL.Parameters.Add(ud.name); insertSQL.Parameters.Add(ud.userblob); Console.WriteLine("!!!"); insertSQL.ExecuteNonQuery(); Console.WriteLine("DONE"); } catch (Exception e) { Console.WriteLine(e.StackTrace); } finally { m_dbConnection.Close(); } } 