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地址')
解决方案 »
- delphi调试输出语句
- 字符串问题.
- combobox问题
- 在线等待,解决立刻结贴!关于XP下的程序在98下执行程序控件上的字都变成???号了
- image的问题
- 这个组件为什么不能保存上一次的值?在线等等.
- 我的delphi为什么只能实现一步undo,是不是要设置一下啊?
- 添加数据库记录时的错误报告:Violation of PRIMARY KEY constrait 'PK_yfjb0'.Cannot insert duplicate key in object 'yfjb0'怎么解决?
- 图像被选中的制作
- Ado显示问题,高分请教
- 问题真那么难么?五星都没看出来?
- 求汉字的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;