adoconnection问题? 写了一个存储过程(adostoredproc)返回记录时总是,报can't not perform this when dataset is closed? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 adoconnection 打开了吗?adoconnection.connect := true; 我在try 语句写adoconnction的连接的及adostroedproc.execproc,而且通过了,但用adostroedproc.state试了一下,竟然是dsinactive,可能没连上??? 我又试了一次,连接是成功的,不知是否是bug,我用的是6.0 晕了,越来越糊涂了,加个adoconnection空间,选中connection属性,选好驱动,数据库,密码等属性,测试连接,成功!然后选中connected:true,竟弹出:连接失败!!!!!为什么会这样? 不知道你用adoconnection得connectionstring属性中是怎么设置的 procedure Tfrm_PriceQuery.Research_btnClick(Sender: TObject);var _key :string; _brand :string; _name :string; _origin :string; _catalog :string; _adoconn :TADOCONNECTION; _adoproc :TADOSTOREDPROC; ... begin try begin _adoconn:=TADOCONNECTION.Create(nil); _adoproc:=TADOSTOREDPROC.Create(nil); _doconnectionString:='Provider=SQLOLEDB.1;Password=****;Persist Security Info=True;User ID=*****;Initial Catalog=****;Data Source=****;'; _adoconn.LoginPrompt:=false; _adoconn.Connected:=true; end except begin showmessage('连接失败'); exit; end; end; _key :=trim(Cyberedit1.Text); _brand:=trim(CyberEdit2.Text); _name :=trim(CyberEdit3.Text); _catalog:=trim(CatalogCOB.SelText); _origin :=trim(OriginCOB.SelText); _adoproc.Connection:=_adoconn; _adoproc.ProcedureName:='sp_PriceQuery'; _adoproc.Parameters.CreateParameter('key',ftString,pdinput,50,_key); _adoproc.Parameters.CreateParameter('brand',ftString,pdinput,50,_brand); _adoproc.Parameters.CreateParameter('name',ftString,pdinput,50,_name); _adoproc.Parameters.CreateParameter('catalog',ftString,pdinput,50,_catalog); _adoproc.Parameters.CreateParameter('origin',ftString,pdinput,255,_origin); _adoproc.Parameters.CreateParameter('result',ftString,pdoutput,20,null); try begin _adoproc.Prepared:=true; _adoproc.ExecProc; end except begin showmessage('失败'); exit; end; end; if _adoproc.RecordCount>0 then begin while not _adoproc.Eof do begin .... _adoproc.Next; end; end; _adoproc.Parameters.ParamByName('key').Free; _adoproc.Parameters.ParamByName('brand').Free; _adoproc.Parameters.ParamByName('name').Free; _adoproc.Parameters.ParamByName('catalog').Free; _adoproc.Parameters.ParamByName('origin').Free; _adoproc.Free;end;我试了几次了,连数据库时好象没多大问题,倒是在执行存储过程时有这个问题: oleexception: 语法错误或访问冲突???? 谁能提供一下思路? 关于多台电脑的通讯 InstallShield 12 乱码问题? 自定义字体大小 关于MDI窗体的问题 小弟有点迷茫,望达人指点,同时散分 对每页的记录中的字段如何进行统计求和并在该页页脚显示----分全给了 一个RichEdit的疑惑 在DELPHI中如何检查内存泄漏,boundchecker如何用呀? 这个小问题怎么解决?大侠帮忙啊!!急~~~~~~~~ 让我们改变字段! Delphi怎样注释一段文字? VC中用/**/ 小小与祈晴娃娃及爱翔技术交流三 分析。
但用adostroedproc.state试了一下,竟然是dsinactive,可能没连上???
加个adoconnection空间,选中connection属性,选好驱动,数据库,密码等属性,测试连接,成功!
然后选中connected:true,竟弹出:连接失败!!!!!
为什么会这样?
var
_key :string;
_brand :string;
_name :string;
_origin :string;
_catalog :string;
_adoconn :TADOCONNECTION;
_adoproc :TADOSTOREDPROC;
...
begin
try
begin
_adoconn:=TADOCONNECTION.Create(nil);
_adoproc:=TADOSTOREDPROC.Create(nil); _doconnectionString:='Provider=SQLOLEDB.1;Password=****;Persist Security Info=True;User ID=*****;
Initial Catalog=****;Data Source=****;';
_adoconn.LoginPrompt:=false;
_adoconn.Connected:=true;
end
except
begin
showmessage('连接失败');
exit;
end;
end;
_key :=trim(Cyberedit1.Text);
_brand:=trim(CyberEdit2.Text);
_name :=trim(CyberEdit3.Text);
_catalog:=trim(CatalogCOB.SelText);
_origin :=trim(OriginCOB.SelText);
_adoproc.Connection:=_adoconn;
_adoproc.ProcedureName:='sp_PriceQuery';
_adoproc.Parameters.CreateParameter('key',ftString,pdinput,50,_key);
_adoproc.Parameters.CreateParameter('brand',ftString,pdinput,50,_brand);
_adoproc.Parameters.CreateParameter('name',ftString,pdinput,50,_name);
_adoproc.Parameters.CreateParameter('catalog',ftString,pdinput,50,_catalog);
_adoproc.Parameters.CreateParameter('origin',ftString,pdinput,255,_origin);
_adoproc.Parameters.CreateParameter('result',ftString,pdoutput,20,null); try
begin
_adoproc.Prepared:=true;
_adoproc.ExecProc;
end
except
begin
showmessage('失败');
exit;
end;
end;
if _adoproc.RecordCount>0 then
begin
while not _adoproc.Eof do
begin
....
_adoproc.Next;
end;
end;
_adoproc.Parameters.ParamByName('key').Free;
_adoproc.Parameters.ParamByName('brand').Free;
_adoproc.Parameters.ParamByName('name').Free;
_adoproc.Parameters.ParamByName('catalog').Free;
_adoproc.Parameters.ParamByName('origin').Free;
_adoproc.Free;end;
我试了几次了,连数据库时好象没多大问题,倒是在执行存储过程时有这个问题:
oleexception: 语法错误或访问冲突????