读书人IT频道reader8.com/exam/jisuanji/动态的连接到数据库的方法: 这里我们创建一个后缀为Ini的文件system.ini,在system.Ini文件中写入如下代码: [DBMS_PROFILES] CURRENTODBC PROFILES [Profile ] DBMS
读书人IT频道reader8.com/exam/jisuanji/ 动态的连接到数据库的方法:
这里我们创建一个后缀为Ini的文件system.ini,在system.Ini文件中写入如下代码:
[DBMS_PROFILES]
CURRENT=ODBC
PROFILES=
[Profile ]
DBMS=
Database=
UserId=
DatabasePassword=
LogPassword=
ServerName=
LogId=
Lock=
DbParm=ConnectString=‘DSN=ora8;UID=;PWD=‘ //ora8指数据库服务器名
Prompt=0
AutoCommit=0
这样在应用程序的open事件中写入下代码:
string ls_inifile
ls_inifile = "system.ini"
// Profile system
SQLCA.DBMS =ProfileString(ls_inifile,"Database", "DBMS", "")
SQLCA.database =ProfileString(ls_inifile,"Database", "database", "")
SQLCA.userid =ProfileString(ls_inifile,"Database", "userid", "")
SQLCA.dbpass =ProfileString(ls_inifile,"Database", "dbpass", "")
SQLCA.LogId =ProfileString(ls_inifile,"Database", "LogId", "")
SQLCA.LogPass =ProfileString(ls_inifile,"Database", "LogPassWord","")
SQLCA.ServerName =ProfileString(ls_inifile,"Database", "ServerName" ,"")
SQLCA.DBParm =ProfileString(ls_inifile,"Database", "DBParm", "")
Connect using sqlca;
open(w_frame)
If sqlca.sqlcode<>0 then
Messagebox("不能连接到数据库",Sqlca.sqlerrtext)
return
end if 读书人IT频道reader8.com/exam/jisuanji/