小弟想编一个通用的DBF查询工具,打开数据库浏览是没问题了,现在要选定一条记录删除,我想把此表所有字段名以及此条记录字段值取出来,放入sql语句“delete from 表名 where 字段名=''''+字段值+''',可是字段属性有整型,有字符还有其他,如何辨别其字段属性,望举例做答!
解决方案 »
- 用 NativeXml 创建一个XML文档时,汉字无法保存?
- 各位高手指点一下关于paintbox的画面显示问题!
- 关于select * from where ...and...and... 语句中,最多可以用多少and??
- 怎么在delphi程序中设置打印机的分辨率,使得打印程序在任何的打印机上打印出的效果都一样
- 关于dll回传值的问题
- 请问如何将DBGrid中的数据打印出来啊?
- 求助有关DBGrid显示格式问题??大侠请进!!!(在线等待,马上给分)
- 如何用SQL语句动态改变dbf表某字段长度(不删除原有数据)?
- 高分诱惑(痛苦莫过于分太多)
- 在Delphi中如何用MS的Messenger发送消息。
- 如何响应回车?????
- 帮看看这个错误
ParamValue: variant;
begin
with tmpQuery do
begin
try
ParamValue := ?
acDatabase.StartTransaction();
SQL.Text := 'delete from 表名 where 字段名 = :随便';
Params[0].Value := ParamValue;
ExecSQL();
acDatabase.Commit();
except
acDatabase.Rollback();
Close;
raise
end;//try
Close;
end;//with
end;
可以用DataSet的DataType的属性
详情请看帮助
FieldNm: string; //字段名
Case GetFieldType(FieldNm) of
1: sValue := QuotedStr(sValue);
2: begin
Try
StrToFloat(sValue);
Except
ShowMessage('"'+sValue+'" is not a virtual value.');
Exit;
End;
end;
3: sValue := VarCntbool(sValue);
4: begin
Try
StrToDateTime(sValue);
Except
ShowMessage('"'+sValue+'" is not a virtual value.');
Exit;
End;
sValue := QuotedStr(sValue);
end;
end;{ 将字符串转为逻辑型值 }
Function TFram_Filter.VarCntbool(value: string): String;
begin
If (UpperCase(Trim(value))='TRUE') or (Trim(value)='1') then
Result := '1'
else
Result := '0';
end;{ 返回字段类型 }
Function TFram_Filter.GetFieldType(FieldNm: string): Integer;
begin
Case FDataSet.FieldbyName(FieldNm).DataType of
ftString, ftWideString, ftFixedChar:
Result := 1;
ftBoolean :
Result := 3;
ftDate, ftTime, ftDateTime:
Result := 4;
else Result := 2;
end;
end;供参考