adoquery1.SQL.Clear ;
adoquery1.SQL.Add('select * from yssj where IP地址='+str[0]+' and MAC地址='+str[4]+'');
adoquery1.Open;
if adoquery1.RecordCount=0 then showmessage('+str[5]+'+'的计算机使用非法IP地址')
adoquery1.SQL.Add('select * from yssj where IP地址='+str[0]+' and MAC地址='+str[4]+'');
adoquery1.Open;
if adoquery1.RecordCount=0 then showmessage('+str[5]+'+'的计算机使用非法IP地址')
解决方案 »
- ADO超时能不能时间短一点? connectiontimeout设置了也不起作用
- 请教大家关于一个导出数据到excel的问题
- 最近发现一个软件,他有部分图片是写在INI文件里头的,全部是数字,不知道是怎么读取并显示的
- 请问各位高手,如何获得MP3音乐的振幅(声强)
- 急问有关mscomm的字节和位关系
- 关于datetimepicker控件的问题!急!
- 在DELPHI编写代码的时候,如果感觉一行写的太长,想换行怎么办??
- 请问类似小新日历,人生日历等,点击系统时间调出程序的功能是怎么实现的?截取消息还是其它别的方法,谢谢大家!
- StrToDateTime函数应该怎么用??
- Delphi 中如何进行端口扫描???(有60分哦)
- 问题真那么难么?五星都没看出来?
- 求汉字的asc码, 参考程序!
adoquery1.SQL.Clear ;
adoquery1.SQL.Add('select * from yssj where IP地址='''+str[0]+''' and MAC地址='''+str[4]+'''');
try
adoquery1.Open;
if adoquery1.RecordCount=0 then showmessage(str[5]+'的计算机使用非法IP地址')
except
showmessage('Error');
end;
adoquery1.SQL.Add('select * from yssj where IP地址='+str[0]+' and MAC地址='+str[4]+'');
adoquery1.Open;
if (adoquery1.IsEmpty) then showmessage('+str[5]+'+'的计算机使用非法IP地址')
adoquery1.close;
adoquery1.SQL.Clear ;
adoquery1.SQL.Text:='select * from yssj where IP地址='''+str[0]+''' and MAC地址='''+str[4]+'''';
try
adoquery1.Open;
if adoquery1.RecordCount=0 then showmessage(str[5]+'的计算机使用非法IP地址')
except
showmessage('Error');
end;
还有,最好不要使用中文字段名称
类似的帖子真多呀。
adoquery1.SQL.Add('select * from yssj');
ADOQuery1.SQL.Add('where IP地址=:IP');
ADOQuery1.SQL.Add('and MAC地址=:MAC');
ADOQuery1.Parameters.ParamByName('IP').Value:=str[0];
ADOQuery1.Parameters.ParamByName('MAC').Value:=str[4];
ADOQuery1.Open ;
if adoquery1.RecordCount=0 then showmessage('+str[5]+'+'的计算机使用非法IP地址');
ADOQuery1.Close;
我这样解决了
存在一些错误,请指教!
for j:=0 to (CurListView.Columns.Count - 1)
do s_h[j]:=trim(FixLenStr(CurListView.Columns[j].Caption, 15));
ADOConnection1.Execute('create table '+newtableName+'('+s_h[0]+' char(50),'+s_h[1]+' char(50),'+s_h[2]+' char(50),'+s_h[3]+' char(50),'+s_h[4]+' char(50))'); for i:=0 to CurListView.Items.Count-1 do
begin
str[0] := FixLenStr(CurListView.Items[i].Caption, 15) ;
for j:=0 to (CurListView.Items[i].SubItems.Count-2) do
str[j+1] :=FixLenStr(CurListView.Items[i].SubItems[j], 15); //判断
ADOQuery1.SQL.Clear ;
ADOQuery1.SQL.Add('select * from yssj where IP地址=:IP');
//ADOQuery1.SQL.Add('where IP地址=:IP');
ADOQuery1.Parameters.ParamByName('IP').Value:=str[0];
ADOQuery1.Open ;
//ADOQuery1.FindFirst;
//ADOQuery1.FieldByName('IP地址');
if ADOQuery1.RecordCount=0 then showmessage('非法的计算机')
else
begin
adoquery1.SQL.Clear ;
adoquery1.SQL.Add('select * from yssj where IP地址=:IP and MAC地址=:MAC');
//ADOQuery1.SQL.Add('where IP地址=:IP');
//ADOQuery1.SQL.Add('and MAC地址=:MAC');
ADOQuery1.Parameters.ParamByName('IP').Value:=str[0];
ADOQuery1.Parameters.ParamByName('MAC').Value:=str[4];
try
ADOQuery1.Open ;
if adoquery1.RecordCount=0 then showmessage('+str[5]+'+'的计算机使用非法IP地址');
except
showmessage('error')
end;
end;
ADOQuery1.Close;
FreeAndNil(ADOQuery1); ADOConnection1.Execute('insert into '+newtableName+' ('+s_h[0]+' ,'+s_h[1]+' ,'+s_h[2]+' ,'+s_h[3]+' ,'+s_h[4]+') values ('+chr(39)+str[0]+chr(39)+','+chr(39)+trim(str[1])+chr(39)+','+chr(39)+trim(str[2])+chr(39)+','+chr(39)+trim(str[3])+chr(39)+','+chr(39)+trim(str[4])+chr(39)+')') end;