private void sql_Insert(string table, MG_ValueSet valueSet, MG_Geometry geometry, out string strSQL, out NpgsqlParameter[] sqlParams) { // oid, field1, field2, field3, field4,...fieldN, geom // INSERT INTO point(f1, f2, f3, geom) VALUES('v1', 'v2', 'v3', ST_GeometryFromText('POINT (100 200)',0)); string str1 = "INSERT INTO {0}("; str1 = String.Format(str1, table); // oid name geom cityno length // name cityno length ArrayList columns = this.GetTableColumnNames(table); string str2 = ""; string str4 = ""; if (columns!= null && valueSet!=null) { string temp1 = "{0}, "; string temp2 = "'{0}', "; int countField = columns.Count; //5 int countValue = valueSet.Count(); // 3 if (countField-2 == countValue) // oid geom { for (int i = 0; i < countField; i++) { string column = columns[i].ToString(); if (!column.Equals("oid") && !column.Equals("geom")) { str2 += String.Format(temp1, column); } } for (int j = 0; j < countValue;j++ ) { str4 += String.Format(temp2, valueSet.GetAt(j).Value); } } } string str3 = "geom) VALUES("; string str5 = "ST_GeometryFromText('{0}',0));"; str5 = String.Format(str5, geometry.AsWKT()); strSQL = str1+str2+str3+str4+str5; sqlParams = null; }