list control 导 excel(字段定义错误)

MFC:我用list control显示数据库中的某个表,根据需要字段名做了更改(数据库中为英文,控件中是中文,有两列列名为:XX(°);有50列列名为:XXXX(摄氏度))

[code=C/C++][/code]
// 创建表结构
  int i;
  LVCOLUMN columnData;
  CString columnName;
  int columnNum = 0;
  CString strH;
  CString strV;

  sSql = "";
  strH = "";
  columnData.mask = LVCF_TEXT;
  columnData.cchTextMax =100;
  columnData.pszText = columnName.GetBuffer (100);
  for(i=0;pList->GetColumn(i,&columnData);i++)
{
  if (i!=0)
{
  sSql = sSql + "," ;
  strH = strH + "," ;
}

  sSql = sSql + columnData.pszText +" TEXT";
  strH = strH + columnData.pszText +" ";

}
  columnName.ReleaseBuffer ();
  columnNum = i;


  sSql = "CREATE TABLE " +strTitle+ " (" + sSql + ")"; //这句字符就好长好长
  database.ExecuteSQL(sSql); //单步到此异常,运行是错误提示:字段定义语法错误
   
  // 插入数据项
……

作者: zcy00772   发布时间: 2011-06-15

C/C++ code
MFC:我用list control显示数据库中的某个表,根据需要字段名做了更改(数据库中为英文,控件中是中文,有两列列名为:XX(°);有50列列名为:XXXX(摄氏度))

[code=C/C++]

// 创建表结构
  int i;
  LVCOLUMN columnData;
  CString columnName;
  int columnNum = 0;
  CString strH;
  CString strV;

  sSql = "";
  strH = "";
  columnData.mask = LVCF_TEXT;
  columnData.cchTextMax =100;
  columnData.pszText = columnName.GetBuffer (100);
  for(i=0;pList->GetColumn(i,&columnData);i++)
{
  if (i!=0)
{
  sSql = sSql + "," ;
  strH = strH + "," ;
}

  sSql = sSql + columnData.pszText +" TEXT";
  strH = strH + columnData.pszText +" ";

}
  columnName.ReleaseBuffer ();
  columnNum = i;


  sSql = "CREATE TABLE " +strTitle+ " (" + sSql + ")"; //这句字符就好长好长
  database.ExecuteSQL(sSql); //单步到此异常,运行是错误提示:字段定义语法错误
   
  // 插入数据项
……[/code]

作者: zcy00772   发布时间: 2011-06-15

C/C++ code
// 创建表结构
  int i;
  LVCOLUMN columnData;
  CString columnName;
  int columnNum = 0;
  CString strH;
  CString strV;

  sSql = "";
  strH = "";
  columnData.mask = LVCF_TEXT;
  columnData.cchTextMax =100;
  columnData.pszText = columnName.GetBuffer (100);
  for(i=0;pList->GetColumn(i,&columnData);i++)
{
  if (i!=0)
{
  sSql = sSql + "," ;
  strH = strH + "," ;
}

  sSql = sSql + columnData.pszText +" TEXT";
  strH = strH + columnData.pszText +" ";

}
  columnName.ReleaseBuffer ();
  columnNum = i;


  sSql = "CREATE TABLE " +strTitle+ " (" + sSql + ")"; //这句字符就好长好长
  database.ExecuteSQL(sSql); //单步到此异常,运行是错误提示:字段定义语法错误
    
  // 插入数据项
……

作者: zcy00772   发布时间: 2011-06-15

上面写错了 有50列列名为:XXXX(℃)

作者: zcy00772   发布时间: 2011-06-15