private string sql_CreateTable(MG_FieldSet fieldSet, MG_GeometryType gt) {// oid, field1, field2, field3, field4,...fieldN, geom //CREATE TABLE point2 ( oid SERIAL PRIMARY KEY, name1 VARCHAR, name2 VARCHAR); SELECT AddGeometryColumn('public','point2','geom',0,'POINT',2); // table name, column name must be lowercase, e.g. pointTABLE --->pointtable string front = "CREATE TABLE {0} ( oid SERIAL PRIMARY KEY"; string table = fieldSet.GetName().ToLower(); front = String.Format(front, table); string m = ", {0} {1}"; string mid = ""; for (int i = 0; i < fieldSet.Count(); i++) { MG_Field field = fieldSet.GetAt(i); mid += String.Format(m, field.Name.ToLower(), field.Type.ToString()); } string end = "); SELECT AddGeometryColumn('public','{0}','geom',0,'{1}',2);"; end = String.Format(end, table, gt.ToString()); string strSQL = front + mid + end; return(strSQL); }
public int CreateTable(MG_FieldSet fieldSet, MG_GeometryType gt) { if (this.IsTableExist(fieldSet.GetName())) { return(0); } this.sql_CreateTable(fieldSet, gt, out m_strSQL, out m_sqlParams); return(this.RunSQL(m_strConn, m_strSQL, m_sqlParams)); }
public int CreateTable(MG_FieldSet fieldSet, MG_GeometryType gt) { if (this.IsTableExist(fieldSet.GetName())) { return(0); } string strSQL = this.sql_CreateTable(fieldSet, gt); return(this.Run(strSQL)); }