// ClearDataConnConfiy.ini //ini配置文件[ServerInfo]
ServerIP=AJAX\SA
SQLDBName=UFDATA_002_2006
SQLUserID=sa
SQLPwd=ajax //以下是 调用ini文件及连接数据库代码 type
QueryClearData: TADOQuery;{读取数据库连接文件 }
function Get_ClearData_Str(FileName:String):String;
var
ServerIP,SQLDBName,SQLUserName,SQLPwd:string;
begin
Result :='';
with TInifile.Create(ExtractFilePath(Paramstr(0))+'ClearDataConnConfiy.ini') do
begin
try
ServerIP:=ReadString('ServerInfo','ServerIP','');
SQLDBName:=ReadString('ServerInfo','SQLDBName','');
SQLUserName:=ReadString('ServerInfo','SQLUserID','');
SQLPwd:=ReadString('ServerInfo','SQLPwd','');
finally
Free;
end;
Result :='Provider=SQLOLEDB.1;Password='+SQLPwd+';Persist Security Info=True;User ID='+SQLUserName+';Initial Catalog='+SQLDBName+';Data Source='+ServerIP;
end; end;
procedure TMainForm.FormShow(Sender: TObject);
var
Ini_FileName:String;
begin
{ 检查数据库时候连接 } Ini_FileName:=ExtractFilePath(application.ExeName)+'ClearDataConnConfiy.ini';
// Ini_FileName:=GetExePath + 'ClearDataConnConfiy.ini'; if not FileExists(Ini_FileName) then
begin
ShowMessage('数据库连接配置文件不存在!');
Application.Terminate;
end
else
begin
with QueryClearData do
begin
//Active:=true;
// Connected := true;
ConnectionString:=Get_ClearData_Str(Ini_FileName);
//Active:=true;
{ try
Connected:=false;
//Active:=false;
except
showMessage('数据库连接失败!请检查配置文件:'+Ini_FileName);
end; } close;
sql.clear;
{sql.Add('select CD1.cWhCode as 仓库编号,CD1.cInvCode as 存货编号,CD1.cBatch as 批号,CD1.iQuantity as 结存数量');
sql.Add('from CurrentStock CD1');
sql.Add('where CD1.iQuantity=0');
}
sql.Add('select * from CurrentStock');
open;
end; end;
end;错误提示:Project LeeO.exe raised exception class EOleException with message '连接字符串属性无效'. process stopped. use step or Run to Continue.折腾了一天了,始终不知道什么问题。
特来求助~~
ServerIP=AJAX\SA
SQLDBName=UFDATA_002_2006
SQLUserID=sa
SQLPwd=ajax //以下是 调用ini文件及连接数据库代码 type
QueryClearData: TADOQuery;{读取数据库连接文件 }
function Get_ClearData_Str(FileName:String):String;
var
ServerIP,SQLDBName,SQLUserName,SQLPwd:string;
begin
Result :='';
with TInifile.Create(ExtractFilePath(Paramstr(0))+'ClearDataConnConfiy.ini') do
begin
try
ServerIP:=ReadString('ServerInfo','ServerIP','');
SQLDBName:=ReadString('ServerInfo','SQLDBName','');
SQLUserName:=ReadString('ServerInfo','SQLUserID','');
SQLPwd:=ReadString('ServerInfo','SQLPwd','');
finally
Free;
end;
Result :='Provider=SQLOLEDB.1;Password='+SQLPwd+';Persist Security Info=True;User ID='+SQLUserName+';Initial Catalog='+SQLDBName+';Data Source='+ServerIP;
end; end;
procedure TMainForm.FormShow(Sender: TObject);
var
Ini_FileName:String;
begin
{ 检查数据库时候连接 } Ini_FileName:=ExtractFilePath(application.ExeName)+'ClearDataConnConfiy.ini';
// Ini_FileName:=GetExePath + 'ClearDataConnConfiy.ini'; if not FileExists(Ini_FileName) then
begin
ShowMessage('数据库连接配置文件不存在!');
Application.Terminate;
end
else
begin
with QueryClearData do
begin
//Active:=true;
// Connected := true;
ConnectionString:=Get_ClearData_Str(Ini_FileName);
//Active:=true;
{ try
Connected:=false;
//Active:=false;
except
showMessage('数据库连接失败!请检查配置文件:'+Ini_FileName);
end; } close;
sql.clear;
{sql.Add('select CD1.cWhCode as 仓库编号,CD1.cInvCode as 存货编号,CD1.cBatch as 批号,CD1.iQuantity as 结存数量');
sql.Add('from CurrentStock CD1');
sql.Add('where CD1.iQuantity=0');
}
sql.Add('select * from CurrentStock');
open;
end; end;
end;错误提示:Project LeeO.exe raised exception class EOleException with message '连接字符串属性无效'. process stopped. use step or Run to Continue.折腾了一天了,始终不知道什么问题。
特来求助~~
解决方案 »
- 又来:Too many actual parameters
- [求助]如何赋DBGRID单元格的初始值
- 传送文件简单问题??
- 急!!!求助:如何打印StringGrid的内容?
- Error] tkzb01.pas(124): Statement expected but 'PROCEDURE' found 是什么意思??在线??
- _______________________________ADO数据库刷新问题!!!____________________
- 如何运行只有*.pas和*.dfm程序?
- 我老大给出的难题。难!(集思广益,言之有理者都有分)
- 用delphi写了个dll,pb调用它时时正常的,可是退出时总报错!
- ??????各位高手,数据库应用程序安装过程中关于数据库路径动态设置的问题??????????
- 如何用文件流来修改文本文件内容?请大侠们指点
- 各位大哥,一个Treeview 跟DBGrid1关联的问题,小弟还是菜鸟,分也不多,只有30分,还请各位大哥相助!!!!
Paramstr(0)如果路径中包含空格的话会出现问题,所以偶一般是用APPLICATION.EXENAME
这是什么??
服务器名可以带'\'的么??这个是非法字符
你只要设
ServerIp=Ajax
就行了吧
ServerIp=Ajax
就行了吧===================================服务器名可以带'\'的么??这个是非法字符
服务器是可以带这个 '\' 字符的。