关于ADOX ,如何通过ADOX取得字段的默认值呢?
如题:
我的代码:
adoxCatalog: _Catalog;
adoxTable: _Table;
adoxColumns: Columns;
窗体创建时: adoxcatalog := cocatalog.Create;
打开表时 :
con1.GetTableNames(cbbTbl.Items, false);
adoxcatalog.Set_ActiveConnection(con1.ConnectionObject);
adoxtable := adoxcatalog.Tables[cbbTbl.ItemIndex + sysTblCount];
//系统表不显示
adoxcolumns := adoxtable.Columns;
然后
with adoxcolumns[colIndex] do
begin
for ipts := Properties.Count - 1 downto 0 do
if properties.item[ipts].Name = 'Default' then
begin
sResult + Properties[ipts].Value;
break;
end;
end;
ShowMessage(sResult);
出现错误,提示
---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EOleException with message '对象或提供者不能执行所需的操作。'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
问题点数:50、回复次数:4Top
1 楼yesin163(破网)回复于 2005-04-05 17:55:22 得分 0
没人回答?Top
2 楼chenylin(陈SIR)回复于 2005-04-05 20:17:44 得分 50
换个思路:
procedure TDataModuleMain.SetDefault(DataSet: TADODataSet; PriField: string);
Var i:Integer;
begin
For i:=0 to DataSet.Fields.Count-1 do
begin
if UpperCase(DataSet.Fields.Fields[i].FieldName)=UpperCase(PriField) then Continue;
Case DataSet.Fields.Fields[i].DataType of
ftString,ftFixedChar, ftWideString :
DataSet.Fields.Fields[i].Value:='';
ftLargeint,ftSmallint, ftInteger, ftWord, ftBoolean, ftFloat, ftCurrency, ftBCD :
DataSet.Fields.Fields[i].Value:=0;
end;
end;
end;
Top
3 楼yesin163(破网)回复于 2005-04-07 13:32:07 得分 0
呵呵,不好意思,也许我没说清楚,我是说在sql里面已经设置好默认值了,我现在想用ADOX取出这个默认值,而不是设置默认值.
谢谢.请继续Top
4 楼yesin163(破网)回复于 2005-04-12 09:08:24 得分 0
没人回答?? 郁闷 ...Top




