procedure Tadd.panduan;
var
usertel:string;
a,b,c:integer;
begin
usertel:=edit1.Text; ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.sql.add('select count(*) from meetmaster');
ADOQuery1.sql.add('where n_tel='+''''+usertel+''''+'and n_=1');
try
ADOQuery1.open;
except
ADOQuery1.ExecSQL;
end;
edit3.Text:=inttostr((ADOQuery1.Fields[0].Value)+1);
end;我的这个工程,编译时顺利通过,但是运行的时候就会报错(project meet.exe raised exception class eaccessviolation with message 'access violation at address 1F487CAB in module 'msado15.dll'.write of address 0182CD2C '.process stopped ,use stepped.use step orrun to continue.),问题就是出在这段过程上,如果我输入的usertel存在的话,应该是编译和运行都没有错误,如果我输入的usertel的值在数据库中没有的话,就会在运行时报错.我想不明白的就是我已经用的时try和except这种形式写的,就即使是没有返回结果也不会报错的嘛??? 请大家帮忙想想,非常急切!!!
var
usertel:string;
a,b,c:integer;
begin
usertel:=edit1.Text; ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.sql.add('select count(*) from meetmaster');
ADOQuery1.sql.add('where n_tel='+''''+usertel+''''+'and n_=1');
try
ADOQuery1.open;
except
ADOQuery1.ExecSQL;
end;
edit3.Text:=inttostr((ADOQuery1.Fields[0].Value)+1);
end;我的这个工程,编译时顺利通过,但是运行的时候就会报错(project meet.exe raised exception class eaccessviolation with message 'access violation at address 1F487CAB in module 'msado15.dll'.write of address 0182CD2C '.process stopped ,use stepped.use step orrun to continue.),问题就是出在这段过程上,如果我输入的usertel存在的话,应该是编译和运行都没有错误,如果我输入的usertel的值在数据库中没有的话,就会在运行时报错.我想不明白的就是我已经用的时try和except这种形式写的,就即使是没有返回结果也不会报错的嘛??? 请大家帮忙想想,非常急切!!!
解决方案 »
- 深夜求助,delphi中一个问题
- 带参数的ms sql server的扩展存储过程,怎么传递参数?
- 如何同步两个memo
- 求如何改变输入时闪动的光标形状?
- 记录隐藏
- D6中try…except…是不是有问题?
- 我是delphi的初学者,请问?
- 关于Tlabel和TPopupMenu控件关联的问题!
- 各位进来看看有关与dll文件的问题!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- 有谁能告诉我16位和32位编程系统内部处理时差别在哪里?说具体点哦﹐谢谢啦|||
- [Help]ListBox使用
- 我用ToolBar做MDI程序的主菜单,为何在子窗口菜单不能加到主窗口的ToolBar菜单里呢? 我以做了,GroupIndex设置呢.为什么还不对?
insert ,update 才用execsql
var
usertel: string;
a, b, c: integer;
begin
usertel := edit1.Text; ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.sql.add('select count(*) from meetmaster ');
ADOQuery1.sql.add('where n_tel=' + QuotedStr(usertel) + ' and n_=1');
try
ADOQuery1.open;
edit3.Text := ADOQuery1.Fields[0].AsString;
except
showmessage('查询出错');
end;
end;
var
usertel:string;
a,b,c:integer;
begin
usertel:=edit1.Text;ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.sql.add('select count(*) from meetmaster');
ADOQuery1.sql.add('where n_tel='+''''+usertel+''''+'and n_=1');
try
ADOQuery1.ExecSQL; 我尝试过了这样的话就不会报错了,但是用了execsql,我又得不到返回的结果
except
//ADOQuery1.ExecSQL;
end;
//edit3.Text:=inttostr((ADOQuery1.Fields[0].Value)+1);请大家根据这一系列的线索再想想..
end;
try
if (判断输入的usertel的值是不是在数据库中存在) then
begin
ADOQuery1.open;
ADOQuery1.ExecSQL;
end;
except
showmsg('XXXXXXXX');
exit;
end;
问题是该怎么样判断呢??
希望大家写出语句!!
试着把select count(*) from meetmaster ...改为select * from meetmaster...然后判断
ADOQuery1.RecrodeCount是否等于0。看看还报不报错
ADOQuery1.sql.add('where n_tel='+''''+usertel+''''+'and n_=1');---------------------------------------------------------
ADOQuery1.sql.add('select count(*) from meetmaster ');//lose a space?
ADOQuery1.sql.add('where n_tel='+''''+usertel+''''+'and n_=1');
var
usertel:string;
a,b,c:integer;
begin
usertel:=edit1.Text; ADOQuery1.Close;
ADOQuery1.SQL.Clear;
//ADOQuery1.sql.add('select count(*) from meetmaster');
//ADOQuery1.sql.add('where n_tel='+''''+usertel+''''+'and n_=1');
ADOQuery1.sql.add('select * from meetmaster');
ADOQuery1.sql.add('where n_tel=' + QuotedStr(usertel) + ' and n_=1');
try
ADOQuery1.open;
except
ADOQuery1.ExecSQL;
end;
a:=ADOQuery1.RecordCount;
//edit3.Text:=inttostr(ADOQuery1.Fields[0].Value);
if a=0 then
showmessage('记录条数为0')
else
showmessage('记录条数不为0');
end;我把程序改成这样以后又试了一下,程序运行起来以后,显示了'记录条数为0'后再次出现以前那个一样的提示(project meet.exe raised exception class eaccessviolation with message 'access violation at address 1F487CAB in module 'msado15.dll'.write of address 0182CD2C '.process stopped ,use stepped.use step orrun to continue.)
var
usertel:string;
a,b,c:integer;
begin
usertel:=edit1.Text;ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.sql.add('select count(*)as tmp from meetmaster');
ADOQuery1.sql.add('where n_tel=:ntel and n_=1');
adoquery1.parameters.parambyname('ntel').value:=usertel;
adoquery1.open;edit3.Text:=ADOQuery1.fieldbyname('tmp').asinteger+1;
end;
end;
基本可以定性為MSADO的問題了,請升級或補丁
記錄為0是你SQL語句的問題.
我另外用了一个ADOQurey4(ADOQurey1有其他的地方也在用,但是我每次使用之都都"ADOQuery1.Close"了的呀!!!),语句的内容基本上没有修改,只是把语句中的ADOQurey1改成了ADOQurey4,居然在运行的时候没问题了(现在ADOQuery4只有这一处在用了)
希望高手站出来分析分析,出问题的本质原因在什么地方!!!????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????