aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/PGSQL/PGSQLEstateData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/PGSQL/PGSQLEstateData.cs')
-rw-r--r--OpenSim/Data/PGSQL/PGSQLEstateData.cs14
1 files changed, 9 insertions, 5 deletions
diff --git a/OpenSim/Data/PGSQL/PGSQLEstateData.cs b/OpenSim/Data/PGSQL/PGSQLEstateData.cs
index 347baf3..141b8ed 100644
--- a/OpenSim/Data/PGSQL/PGSQLEstateData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLEstateData.cs
@@ -201,11 +201,10 @@ namespace OpenSim.Data.PGSQL
201 201
202 string sql = string.Format("insert into estate_settings (\"{0}\") values ( :{1} )", String.Join("\",\"", names.ToArray()), String.Join(", :", names.ToArray())); 202 string sql = string.Format("insert into estate_settings (\"{0}\") values ( :{1} )", String.Join("\",\"", names.ToArray()), String.Join(", :", names.ToArray()));
203 203
204 m_log.Debug("[DB ESTATE]: SQL: " + sql);
205 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) 204 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
206 using (NpgsqlCommand insertCommand = new NpgsqlCommand(sql, conn)) 205 using (NpgsqlCommand insertCommand = new NpgsqlCommand(sql, conn))
207 { 206 {
208 insertCommand.CommandText = sql + "; Select cast(lastval() as int) as ID ;"; 207 insertCommand.CommandText = sql;
209 208
210 foreach (string name in names) 209 foreach (string name in names)
211 { 210 {
@@ -218,11 +217,16 @@ namespace OpenSim.Data.PGSQL
218 217
219 es.EstateID = 100; 218 es.EstateID = 100;
220 219
221 using (NpgsqlDataReader result = insertCommand.ExecuteReader()) 220 if (insertCommand.ExecuteNonQuery() > 0)
222 { 221 {
223 if (result.Read()) 222 insertCommand.CommandText = "Select cast(lastval() as int) as ID ;";
223
224 using (NpgsqlDataReader result = insertCommand.ExecuteReader())
224 { 225 {
225 es.EstateID = (uint)result.GetInt32(0); 226 if (result.Read())
227 {
228 es.EstateID = (uint)result.GetInt32(0);
229 }
226 } 230 }
227 } 231 }
228 232