ACCESS 获取字段数据类型(DATA_TYPE)时出现的问题

  • Post author:
  • Post category:其他


数字类型得到的是3

长文本得到的是130

有知道的吗,谢谢

SAFEARRAY FAR* psa = NULL;
	SAFEARRAYBOUND rgsabound;
	_variant_t  var;
	_variant_t  Array;

	rgsabound.lLbound = 0;
	rgsabound.cElements = 4;
	psa = SafeArrayCreate(VT_VARIANT, 1, &rgsabound);

	var.vt = VT_EMPTY;

	long ix;
	ix = 0;
	SafeArrayPutElement(psa, &ix, &var);

	ix = 1;
	SafeArrayPutElement(psa, &ix, &var);

	ix = 2;
	var.vt = VT_BSTR;
	char * s1 = "";
	_bstr_t str = table.GetBuffer(0);
	var.bstrVal = str;
	SafeArrayPutElement(psa, &ix, &var);	

	var.vt = VT_EMPTY;
	ix = 3;
	SafeArrayPutElement(psa, &ix, &var);

	Array.vt = VT_ARRAY | VT_VARIANT;
	Array.parray = psa;

	_RecordsetPtr _adSchemaColumns = m_conn->OpenSchema(adSchemaColumns, Array);
	while ((!_adSchemaColumns->adoEOF) )
	{
		_bstr_t table_name = _adSchemaColumns->Fields->GetItem("TABLE_NAME")->Value;
		
		{
			_adodb_field field;
			_bstr_t column_name = _adSchemaColumns->Fields->GetItem("COLUMN_NAME")->Value;
			field.name = _com_util::ConvertBSTRToString(column_name);
			VT_I2;
			_variant_t vt_data_type = _adSchemaColumns->Fields->GetItem("DATA_TYPE")->Value;
			_bstr_t data_type = vt_data_type;
			field.type = _com_util::ConvertBSTRToString(data_type);

			printf("Column Name: %s\n", (LPCSTR)data_type);

			//同一个表的列在一起
			_adSchemaColumns->MoveNext();
		}
	}
	return FALSE;



版权声明:本文为ruoge2007原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。