请问为何在我的机器里写的ADO连数据库的程序在别人的机上就不行?

birdhaha 2003-12-24 11:28:51
直接用ado连接的远程sql server 2K,就一个应用程序,在我的机器上很好(本机有delphi环境),但在别人的机器上没有delphi环境的就报连不上服务器,是不是程序编译时还需要加什么东西上去?
...全文
29 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
birdhaha 2003-12-27
  • 打赏
  • 举报
回复
多谢各位!
别人的机器是2K的机器,我用的是Ado方式,与ODBC无关吧?
我在别人的机器上装了mdac2.8(微软主页上下的),就解决问题了。
不过真的多谢各位了!
renzhongguo 2003-12-26
  • 打赏
  • 举报
回复
uses inifiles;
var inifile:tinifile;
strconnection:string;//数据库连接字符串

inifile:=tinifile.Create('c:\information.ini');//打开ini文件
//读出ini文件的数据库配置信息
strconnection:='Provider='+inifile.Readstring('数据库连接','Provider','')+';';
strconnection:=strconnection+'Persist Security Info='+ inifile.Readstring('数据库连接','Persist Security Info','')+';';
strconnection:=strconnection+ 'User ID='+inifile.Readstring('数据库连接','User ID','sa')+';';
strconnection:=strconnection+ 'Initial Catalog='+ inifile.Readstring('数据库连接','Initial Catalog','')+';';
if inifile.Readstring('数据库连接','Data Source','')<>'' then
strconnection:=strconnection+ 'Data Source='+ inifile.Readstring('数据库连接','Data Source','')+';';
strconnection:=strconnection+ 'Locale Identifier='+ inifile.Readstring('数据库连接','Locale Identifier','2052')+';';
strconnection:=strconnection+ 'Connect Timeout='+ inifile.Readstring('数据库连接','Connect Timeout','15')+';';
strconnection:=strconnection+ 'Use Procedure for Prepare='+ inifile.Readstring('数据库连接','Use Procedure for Prepare','1')+';';
strconnection:=strconnection+ 'Auto Translate='+inifile.Readstring('数据库连接','Auto Translate','')+';';
strconnection:=strconnection+ 'Packet Size='+inifile.Readstring('数据库连接','Packet Size','4096')+';';
strconnection:=strconnection+ 'Workstation ID='+inifile.Readstring('数据库连接','Workstation ID','');
//连接数据库
with ADOConnection1 do
begin
Connected:=false;
ConnectionString:=strconnection;
try
connected:=true;
except
application.MessageBox('数据库联接错误!请执行数据库联接程序。','物业管理',MB_ICONERROR+mb_ok);
application.Terminate;//退出程序
end; //end try
end;//end with

下面是ini文件结构
[数据库连接]
Provider=SQLOLEDB.1
Persist Security Info=False
User ID=sa
Initial Catalog=此处填写需要连接的数据库的名字
Data Source=此处填写数据库所在的机器名字
Locale Identifier=2052
Connect TimeOut=10
Use Procedure for Prepare=1
Auto Translate=True
Packet Size=4096

以后修改ini文件的内容就行啦,(修改机器名字),不需要修改程序,不需要设置odbc。
rcllb 2003-12-26
  • 打赏
  • 举报
回复
安装mdac2.7以上版本试试
昵称不腻 2003-12-25
  • 打赏
  • 举报
回复
98的机子要装一下MDAC
siwuge 2003-12-25
  • 打赏
  • 举报
回复
只会帮顶。
elitegroup 2003-12-25
  • 打赏
  • 举报
回复
去那台没delphi 的机器上,装 ADO 的控件(或BDE 驱动)吧!!!
ziqing 2003-12-25
  • 打赏
  • 举报
回复
如果用ODBC的话不用DLL,不过看看你的连接方式对否,是不是动态连接!!!
sandzou 2003-12-25
  • 打赏
  • 举报
回复
1:odbc的问题,如果你用odbc连接的话!!!

2:如果没有以用odbc连接
是安全认证的问题
你看看sql server的认证方式是什么?
问题就在那里
sophia531 2003-12-25
  • 打赏
  • 举报
回复
动态创建ADO的连接,使用相对路径就可以了
AdoConn.Connected:=false;
spath:=ExtractFilePath(Application.ExeName)+'\data\mlcz.mdb';
AdoConn.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+spath+';Persist Security Info=False';
AdoConn.Connected:=true;
VeryOldMan 2003-12-24
  • 打赏
  • 举报
回复
你应该检查一下你程序中连接sql server 2K的方式,以及sql server 2K的安全认证管理方式。
noproblem12 2003-12-24
  • 打赏
  • 举报
回复
如果是用odbc的方式来连接的,还要在客户端配置好odbc

如果是用ole的方式连接的,应该没问题了

但是要注意把相应的 bpl 以及dll文件copy到客户端才可以

midas.dll 等等
yxtwolf 2003-12-24
  • 打赏
  • 举报
回复
哥们和我的问题一样等着达者解决吧
http://expert.csdn.net/Expert/topic/2597/2597618.xml?temp=.1880304
Taken 2003-12-24
  • 打赏
  • 举报
回复
应该检查连接方式和数据库验证方式
jmya 2003-12-24
  • 打赏
  • 举报
回复
你是以什么方式联接数据库的,如果是ODBC,应配置ODBC

2,498

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧