Azavea.NijPredictivePolicing.Parsers.AccessDBValueWriter.CreateTable C# (CSharp) Method

CreateTable() public method

public CreateTable ( string tablename, IEnumerable columns ) : bool
tablename string
columns IEnumerable
return bool
        public bool CreateTable(string tablename, IEnumerable<string> columns)
        {
            if (!IsOpen())
                return false;

            TableNames();
            if ((_tablenames != null) && (_tablenames.Contains(tablename)))
                return false;

            StringBuilder nt = new StringBuilder(1024);

            nt.AppendFormat("CREATE TABLE {0} (", tablename);

            bool firstThru = true;
            foreach (string col in columns)
            {
                if (!firstThru)
                    nt.Append(", ");

                //if (col.ToLower().EndsWith("id"))
                //{
                //    nt.Append(col).Append(" INT");
                //}
                //else
                //{
                    nt.Append(col).Append(" VARCHAR(250)");
                //}

                firstThru = false;
            }
            nt.Append("); ");

            DbCommand cmd = _conn.CreateCommand();
            cmd.CommandText = nt.ToString();
            int numResults = cmd.ExecuteNonQuery();
            _tablenames.Add(tablename);
            return true;
        }