• 全部
  • API 调用
  • 基础类
  • 控件与界面
  • 数据库相关
  • DataWindow
  • 项目管理
  • Web 应用
  • 脚本语言

我用 profilestring来连接sql数据库,结果出错,求救!!

wangmin_yjitx 2003-05-20 08:28:33
代码如下:
sqlca.DBMS = profilestring("connect.ini",database,"DBMS"," ")
sqlca.Database = profilestring("connect.ini",database,"Database"," ")
sqlca.ServerName = profilestring("connect.ini",database,"ServerName"," ")
sqlca.LogId = profilestring("connect.ini",database,"LogId"," ")
sqlca.LogPass =''
sqlca.AutoCommit =false
sqlca.DBParm = profilestring("connect.ini",database,"DBParm"," ")
系统指第一行的"database" 没有定义,后来我定义 dabase为string,但连接不上数据库
这是怎么一回事啊?
...全文
17 点赞 收藏 5
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
bobi1314 2003-05-21
if not fileexists(file_ini) then
messagebox('系统信息','程序的配置文件 '+file_ini+' 不存在,请设置配置文件!')
return
end if
//--连接数据库
SQLCA.DBMS =ProfileString(file_ini,"Database","DBMS","")
SQLCA.Database =ProfileString(file_ini,"Database","Database","")
SQLCA.LogID =ProfileString(file_ini,"Database","LogID","")
SQLCA.LogPass =ProfileString(file_ini,"Database","LogPass","")
SQLCA.ServerName =ProfileString(file_ini,"Database","ServerName","")
SQLCA.UserID =ProfileString(file_ini,"Database","UserID","")
SQLCA.DBPass =ProfileString(file_ini,"Database","DBPass","")
SQLCA.Lock =ProfileString(file_ini,"Database","Lock","")
SQLCA.DbParm =ProfileString(file_ini,"Database","DbParm","")

sqlca.autocommit = true
connect; //数据库连接

if sqlca.sqocode <> -1 then
messagebox("系统提示","数据库连接成功!")
//可以进入系统
else
messagebox("错误提示","数据库连接失败!")
halt;
end if
file_ini:是数据库配置文件名字,是字符串形式。
请试用一下,这代码我用在了30个系统上没有什么问题。
回复
fengkyf001 2003-05-21
database是file_ini文件中一个子目录,
如果file_ini内容如下:

[prof_database]
dbms=sqlsever
...

则应写成如下样式:
sqlca.DBMS = profilestring("connect.ini",”prof_database“,"DBMS"," ")

回复
pbtech 2003-05-20
同意freeliu()
回复
freeliu 2003-05-20
sqlca.DBMS = profilestring("connect.ini","database","DBMS"," ")
sqlca.Database = profilestring("connect.ini","database","Database"," ")
sqlca.ServerName = profilestring("connect.ini","database","ServerName"," ")
sqlca.LogId = profilestring("connect.ini","database","LogId"," ")

database也要用引号扩起来。
回复
twb88 2003-05-20
sqlca.DBMS = profilestring("connect.ini",database,"DBMS","your dbms ")
回复
相关推荐
发帖
PowerBuilder
创建于2007-09-28

863

社区成员

PowerBuilder 相关问题讨论
申请成为版主
帖子事件
创建了帖子
2003-05-20 08:28
社区公告
暂无公告