我的程序是在A机上写的,用的是A机上的数据库SQL2000,用DELPHI6.0的ADO和BDE(Query)连接数据库 ,在A机上编译通过,其中用BDE的时候要输入用户名和密码,可生成EXE文件,可执行把他拷贝到B机上也可以执行EXE文件,但是把程序拿到B机上编译老是出错,说 project project1.exe
raised expection class EoleExpection with message“连接字符串属性无效”。press stop,setup or run to continue。 应如何解决? 我B机也是用SQL2000,DELPHI6.0的。
raised expection class EoleExpection with message“连接字符串属性无效”。press stop,setup or run to continue。 应如何解决? 我B机也是用SQL2000,DELPHI6.0的。
解决方案 »
- 求高手指导SQL新建表为什么不能编译!!!
- 怎样用delphi7写一个播放器在WEB上播放?
- 请问各位高手,这样变态的报表怎样画?
- 这个问题怎么写?
- 各位来拿分!请问在delphi中判断某个表是否存在用什么语句?
- 在使用ehlib时dbgrideh有个autofitcolwidths属性,当把它设为true时有些字段无法全部显示,请问有没有自动换行德东西
- 关于PopupMenu很菜的问题
- DELPHI 中如何调用 WORD 的问题?
- 关于日期型变量的计算问题?高分送上^_^!
- 在edit中,怎么控制只能输入数字及小数点,并且小数点不能在最前面以及最后面!
- dd:integer; dd:=(int1/int2);int1除int2 可能有点数或负数,如果获得它的最大整数据.请问用什么涵数??????
- 请问如何每创建一个窗口就在任务栏里显示一个图标?
MyIniFileStr:=TIniFile.Create(IniFileNameStr);
ServerNameStr:=MyIniFileStr.ReadString('DataBase','DataServer','wrong');
DataBaseNameStr:=MyIniFileStr.ReadString('DataBase','DataBaseName','wrong');
UserStr:=MyIniFileStr.ReadString('DataBase','UserName','wrong'); ConnectStr:='provider=SQLOLEDB.1;Persist Security Info=false;'+ //手动配置连接字串
'User ID='+UserStr+';'+
'Initial Catalog='+DataBaseNameStr+';'+
'Data Source='+ServerNameStr;
ADOConnection1.Connected:=false;
ADOConnection1.ConnectionString:=ConnectStr;
ADOConnection1.Connected:=true;
procedure TForm1.FormCreate(Sender: TObject);
begin
ADOConnection1.ConnectionString:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=rsxx;Data Source=AA;Username=bb;Password=111111';
ADOConnection1.LoginPrompt:=false;
ADOQuery1.Connection:=ADOConnection1;
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select xm from jg');
ADOQuery1.Open;
end;
如不想写在程序里的话,还可以通过读INI文件、注册表及UDL文件(ADO数据链接文件)来实现。
这是制作INI文件原码
implementation
var
myinifile:TInifile;
{$R *.dfm}procedure TForm1.suiButton2Click(Sender: TObject);
begin
close;
end;procedure TForm1.suiButton1Click(Sender: TObject);
var
filename:string;
begin
filename:=ExtractFilePath(paramstr(0))+'zdqreg.ini';
myinifile:=TInifile.Create(filename);
myinifile.writestring('main','DBServerName',trim(suiedit1.Text));
myinifile.writestring('main','DBName',trim(suiedit2.Text));
myinifile.writestring('main','userID',trim(suiedit3.Text));
myinifile.writestring('main','password',trim(pwEncrypt(suiedit4.Text)));
application.MessageBox('注册服务器成功!','提示',64);
end;DLL函数的制作
-----------这个是输出参数
exports
GetRegInfo; //获取注册表信息
--------------------------function GetRegInfo(Flag:Integer):ShortString;
var
filename,p:string;
fp:Tinifile;
begin
filename:= ExtractFilePath(ParamStr(0))+'zdqreg.ini';
fp:=Tinifile.create(filename);
case Flag of
1:begin //1数据库服务器名称
p := 'DBServerName';
end;
2:begin //数据库名称
p := 'DBName';
end;
3:begin //登陆帐号
p := 'userID';
end;
4:begin //登陆密码
p := 'password';
end;
5:begin //连接方式
p := 'LinkAppsMode';
end;
end;
Result:=fp.readstring('main',p,'');
end;在DELPHI中调用
var
Form1: TForm1;
Function GetRegInfo(Flag:Integer):ShortString;external 'zdqreg.dll';//导入DLL
implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
ADOConnection1.ConnectionString:=' Provider=SQLOLEDB.1;'+'Persist Security Info=False;User ID='+GetRegInfo(3)+';Password='+GetRegInfo(4)+';'+
'Initial Catalog='+GetRegInfo(2)+';Data Source='+GetRegInfo(1);
end;end.你看看做DLL和INI文件的操作应该很快就会了,有问题再发信息给我
建议在数据库连接的时候用一种连接方式,我是比较习惯用ADO
而且连接数据库的时候最好用一个DATAMODAL,并且尽量在数据库连接的时候用代码来实现。
你用动态连接吧
或者就用access,ado,sqlserver,不用bde
---connect.ini文件--
[connect]
Server=DB
DB=rsx
User=sa
Ps=6148
-------------
unit yonghudenglu;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, Mask, DB, DBTables, ADODB,inifiles;type
TF_yonghudenglu = class(TForm)
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
ComboBox1: TComboBox;
MaskEdit1: TMaskEdit;
ADOQuery1: TADOQuery;
ADOConnection1: TADOConnection;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
F_yonghudenglu: TF_yonghudenglu;
implementationuses main, quanxianguanli, DM_xt, datersda;{$R *.dfm}procedure TF_yonghudenglu.BitBtn1Click(Sender: TObject);
//取消按钮
begin
close;
end;procedure TF_yonghudenglu.BitBtn2Click(Sender: TObject);
begin
if Combobox1.Text='' then
Combobox1.SetFocus
else if trim(maskedit1.Text)='' then
maskedit1.SetFocus
else
begin
with DM_xt_shujuku do
begin
ADOQ_denglu.Close;
ADOQ_denglu.SQL.Clear;
ADOQ_denglu.SQL.Add('select rybh,mm,xm from users ');
ADOQ_denglu.SQL.Add('where ltrim(rtrim(rybh))='+''''+trim(Combobox1.Text)+'''');
ADOQ_denglu.SQL.Add(' and ltrim(rtrim(mm))='+''''+trim(maskedit1.text)+'''');
ADOQ_denglu.Open;
if (ADOQ_denglu.RecordCount<>1) or
(trim(maskedit1.Text)<>trim(ADOQ_denglu.FieldValues['mm'])) then
begin
showmessage('口令不对,请检查。');
MaskEdit1.Text:='';
MaskEdit1.SetFocus ;
end
else
begin
F_main.StatusBar1.Panels[1].text:=' '+ComboBox1.Text;
F_yonghudenglu.Visible:=false;
F_quanxianguanli.READ_BMAM_PMS(pms_rybh,pms_mkbs);
F_main.ShowModal;
F_yonghudenglu.Close;
end;
end;
end;
end;procedure TF_yonghudenglu.FormShow(Sender: TObject);
begin
Combobox1.Text:='';
maskedit1.Text:='';
end;procedure TF_yonghudenglu.FormActivate(Sender: TObject);
begin
Combobox1.SetFocus;
end;procedure TF_yonghudenglu.FormCreate(Sender: TObject);
var
filename:string;
ConnectIni:TIniFile;
servername,DB,User,Ps:string;
begin
filename:=ExtractFilePath(paramstr(0))+'connect.ini';
ConnectIni:=TInifile.Create(filename);
ServerName:=ConnectIni.ReadString('connect','server','null');
DB:=ConnectIni.ReadString('connect','DB','null');
User:=ConnectIni.ReadString('connect','User','null');
Ps:=ConnectIni.ReadString('connect','Ps','null');
AdoConnection1.ConnectionString:='Provider=SQLOLEDB.1;Password='+ps+';Persist Security Info=True;';
AdoConnection1.ConnectionString:=AdoConnection1.ConnectionString+'User ID='+User+';Initial Catalog='+DB+';Data Source='+ServerName+'';
AdoConnection1.Connected:=True;
ADOConnection1.LoginPrompt:=false;
ADOQuery1.Connection:=ADOConnection1;
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select rybh from users');
ADOQuery1.open;
while not ADOQuery1.EOF do
begin
combobox1.Items.Add(ADOQuery1.FieldValues['rybh']);
ADOQuery1.next;
end;end;end.
错误的解决方法就是重启看看,是编译器出错了,重启都不行的话,那就没有办法了,我以前也遇过这样的情况