我有一个Access 数据库, test.mdb里面有一个简单的数据表 test,只有两列: Id, num,都是数字类型,然后我为这个Access 数据库建立了一个ODBC数据源TestODBC。但是现在我用ADOTable访问这个ODBC数据源TestODBC里面的test表时老是出错:Project test.exe raised exception class EVariantTypeCaseError with message
'Could not convert variant of type (Null) into type (String)'. Process
stopped.......大家试一下,这个问题怎么解决???急。
'Could not convert variant of type (Null) into type (String)'. Process
stopped.......大家试一下,这个问题怎么解决???急。
ADOTable1->Active = false;
ADOTable1->Connection = ADOConnection1;
ADOTable1->TableName = "test";
ADOTable1->Active = true;
----------------------那个问题估计是由于ADOTable控件内部的bug引起,即使你用try{}catch(...)
也是捕捉不到那个异常的,
解决方法就是用ADOQuery替代ADOTable,其实ADOTable无非就是ADOQuery的一个特例吧,因为ADOTable就相当于ADOQuery的sql语句为: select * from Tbl1.
ADOConnection1->Connected = false;
ADOConnection1->ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=TESTDB";
ADOConnection1->Connected = true;
ADOQuery1->Close();
ADOQuery1->Connection = ADOConnection1;
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("select * from " + Edit1->Text);
ADOQuery1->Open();