J
JUMP1972
Unregistered / Unconfirmed
GUEST, unregistred user!
在DLL中导出的一个函数:传入一个格式文件路径,一个编号,一个日期,及返回的字符串
部分代码如下:
function GetCustPowerFee(TicketFilePath,Account_id,ym:string;QueryTxtChar):integer;
var
F:TextFile;
ADOCon:TADOConnection;
ADODataSet1:TADODataSet;
QueryTxt1,QueryTxt2:Widestring;
TicketFileName1,TicketFileName2,TmpStr,TmpStr2,FmtStr1,FmtStr2:string;
FixLen1,FixLen2,i,iPos:integer;
AppPath,DataSource,DBName,UID,Pwd:string;
begin
Result:=0;
QueryTxt1:='';
QueryTxt2:='';
FixLen1:=20;
FixLen2:=16;
AppPath:=ExtractFilePath(Application.ExeName);
with TIniFile.Create(AppPath+'DSFile.ini') do
try //从配置文件中读出连接字符串的参数
DataSource:=ReadString('DataSourceSet','DBServerIP','');
UID:=ReadString('DataSourceSet','UID','');
Pwd:=ReadString('DataSourceSet','PWD','');
DBName:=ReadString('DataSourceSet','DBName','');
finally
Free;
end;
ConnFmt:='Provider=SQLOLEDB.1;Persist Security Info=false;Data Source=%s;'+
'Initial Catalog=%s;User ID=%s;PassWord=%s';
// ADOCon:=TADOConnection.Create(Application);
ADOCon:=TADOConnection.Create(nil);
with ADOCon do
try
Connected:=false;
KeepConnection:=false;
LoginPrompt:=false;
ConnectionString:=Format(ConnFmt,[DataSource,DBName,UID,pwd])
//出错:OLE错误
Connected:=true;
KeepConnection:=true;
ADODataSet1:=TADODataSet.Create(Application);
with ADODataSet1 do //取电费数据
try
Connection:=ADOCon;
CommandType:=cmdStoredProc;
Active:=false;
if Parameters.Count>0 then Parameters.Refresh;
CommandText:='p_GetCustPowerFee';
Parameters.Refresh;
Parameters[1].Value:=Account_id;
Parameters[2].Value:=StrToInt(Copy(ym,1,4));
Parameters[3].Value:=StrToInt(Copy(ym,5,2));
Active:=true;
不知道为什么出错?
请高手解惑
部分代码如下:
function GetCustPowerFee(TicketFilePath,Account_id,ym:string;QueryTxtChar):integer;
var
F:TextFile;
ADOCon:TADOConnection;
ADODataSet1:TADODataSet;
QueryTxt1,QueryTxt2:Widestring;
TicketFileName1,TicketFileName2,TmpStr,TmpStr2,FmtStr1,FmtStr2:string;
FixLen1,FixLen2,i,iPos:integer;
AppPath,DataSource,DBName,UID,Pwd:string;
begin
Result:=0;
QueryTxt1:='';
QueryTxt2:='';
FixLen1:=20;
FixLen2:=16;
AppPath:=ExtractFilePath(Application.ExeName);
with TIniFile.Create(AppPath+'DSFile.ini') do
try //从配置文件中读出连接字符串的参数
DataSource:=ReadString('DataSourceSet','DBServerIP','');
UID:=ReadString('DataSourceSet','UID','');
Pwd:=ReadString('DataSourceSet','PWD','');
DBName:=ReadString('DataSourceSet','DBName','');
finally
Free;
end;
ConnFmt:='Provider=SQLOLEDB.1;Persist Security Info=false;Data Source=%s;'+
'Initial Catalog=%s;User ID=%s;PassWord=%s';
// ADOCon:=TADOConnection.Create(Application);
ADOCon:=TADOConnection.Create(nil);
with ADOCon do
try
Connected:=false;
KeepConnection:=false;
LoginPrompt:=false;
ConnectionString:=Format(ConnFmt,[DataSource,DBName,UID,pwd])
//出错:OLE错误
Connected:=true;
KeepConnection:=true;
ADODataSet1:=TADODataSet.Create(Application);
with ADODataSet1 do //取电费数据
try
Connection:=ADOCon;
CommandType:=cmdStoredProc;
Active:=false;
if Parameters.Count>0 then Parameters.Refresh;
CommandText:='p_GetCustPowerFee';
Parameters.Refresh;
Parameters[1].Value:=Account_id;
Parameters[2].Value:=StrToInt(Copy(ym,1,4));
Parameters[3].Value:=StrToInt(Copy(ym,5,2));
Active:=true;
不知道为什么出错?
请高手解惑