Пример #1
0
    // 쿼리 : 테이블 생성("CREATE TABLE `TableName` (`FieldName1` INTEGER, `FieldName2` INTEGER, `FieldName3` INTEGER);")
    public bool CreateTable(string strTableName, SHTableDataSet pRowDataSet)
    {
        if (null == pRowDataSet)
        {
            return(false);
        }

        string strFields = string.Empty;

        for (int iCol = 0; iCol < pRowDataSet.m_iMaxCol; ++iCol)
        {
            string strColName = pRowDataSet.m_ColumnNames[iCol];
            string strColType = pRowDataSet.m_ColumnTypes[iCol];
            strFields += string.Format("\"{0}\" {1}", strColName, SHTableDataUtil.GetTypeToDB(strColType));

            if (iCol + 1 < pRowDataSet.m_iMaxCol)
            {
                strFields += ", ";
            }
        }

        string strQuery = string.Empty;

        if (string.Empty == strFields)
        {
            strQuery = string.Format("CREATE TABLE \"{0}\";", strTableName);
        }
        else
        {
            strQuery = string.Format("CREATE TABLE \"{0}\" ({1});", strTableName, strFields);
        }

        return(WriteQuery(strQuery));
    }
Пример #2
0
    List <SHTableDataSet> GetTableDataSet(SQLiteQuery pQuery, string strTableName)
    {
        if (null == pQuery)
        {
            return(null);
        }

        var pDataList = new List <SHTableDataSet>();

        while (true == pQuery.Step())
        {
            SHTableDataSet pData      = new SHTableDataSet();
            int            iMaxColumn = pQuery.Names.Length;
            for (int iCol = 0; iCol < iMaxColumn; ++iCol)
            {
                string strColName = pQuery.Names[iCol];
                pData.AddData(strTableName,
                              strColName, SHTableDataUtil.GetTypeToName(strColName),
                              pQuery.GetString(strColName));
            }
            pDataList.Add(pData);
        }
        return(pDataList);
    }