public override bool ToDB(MySqlConnection con, String DBPrefix, TechTreeCache tc) { long scanid = (long)base.ToDB(con, DBPrefix, "schiff", tc); if (scanid == 0) return false; MySqlCommand flInsert = new MySqlCommand("INSERT INTO " + DBPrefix + "scans_flotten (scanid, owner, typ) VALUES (?scanid, ?owner, ?typ)", con); MySqlParameter fl_scanid = flInsert.Parameters.Add("?scanid", MySqlDbType.String); MySqlParameter fl_owner = flInsert.Parameters.Add("?owner", MySqlDbType.String); MySqlParameter fl_typ = flInsert.Parameters.Add("?typ", MySqlDbType.String); flInsert.Prepare(); MySqlCommand schiffsInsert = new MySqlCommand("INSERT INTO " + DBPrefix + "scans_flotten_schiffe (flid, schid, anz) VALUES (?flid, ?schid, ?anz)", con); MySqlParameter sch_flid = schiffsInsert.Parameters.Add("?flid", MySqlDbType.UInt32); MySqlParameter sch_schid = schiffsInsert.Parameters.Add("?schid", MySqlDbType.UInt32); MySqlParameter sch_anz = schiffsInsert.Parameters.Add("?anz", MySqlDbType.UInt32); schiffsInsert.Prepare(); foreach (ScanFlotte fl in Flotten) { fl_scanid.Value = scanid; fl_owner.Value = fl.ownerName; fl_typ.Value = fl.typ; flInsert.ExecuteNonQuery(); sch_flid.Value = flInsert.LastInsertedId; foreach (ScanSchiff s in fl.schiffe) { schiffsInsert.Parameters["?schid"].Value = tc.ID(s.name, "schiff", con, DBPrefix); schiffsInsert.Parameters["?anz"].Value = s.anz; schiffsInsert.ExecuteNonQuery(); } } return true; }
public override bool ToDB(MySqlConnection con, String DBPrefix, TechTreeCache tc) { long scanID = base.ToDB(con, DBPrefix, "geb", tc); if (scanID == 0) return false; MySqlCommand gebInsert = new MySqlCommand("INSERT INTO " + DBPrefix + @"scans_gebs (scanid, gebid, anzahl) VALUES (?scanid, ?gebid, ?anz)", con); gebInsert.Parameters.Add("?scanid", MySqlDbType.UInt32).Value = scanID; gebInsert.Parameters.Add("?gebid", MySqlDbType.UInt32); gebInsert.Parameters.Add("?anz", MySqlDbType.UInt16); gebInsert.Prepare(); foreach (ScanGeb geb in Gebs) { gebInsert.Parameters["?gebid"].Value = tc.ID(geb.name, "geb", con, DBPrefix); gebInsert.Parameters["?anz"].Value = geb.anz; gebInsert.ExecuteNonQuery(); } return true; }