当前位置: 代码迷 >> PB >> 数据库连接 , ini文件及连接代码
  详细解决方案

数据库连接 , ini文件及连接代码

热度:37   发布时间:2016-04-29 09:41:50.0
数据库连接 ,求一个 ini文件及连接代码。
sql 2000或 sql 2005都可以,如果有其他的数据库的也可以。万分感谢

------解决方案--------------------
sqlca.dbms= ProfileString ( ls_inifile, "Database", "DBMS", "ODBC")
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", "")
sqcla.server= ProfileString ( ls_inifile, "Database", "Servername", "")
sqlca.dbparm= ProfileString ( ls_inifile, "Database", "DBParm", "ConnectString='DSN=EAS Demo DB V9;UID=dba;PWD=sql'")
sqlca.lock= ProfileString ( ls_inifile, "Database", "Lock", "")
sqlca.autocommit = ProfileString ( ls_inifile, "Database", "AutoCommit", "false")

connect;

------解决方案--------------------
邮箱地址?我将ini文件及示例代码发过去
------解决方案--------------------
ini
/*
[dbms]
dbms=MSS Microsoft SQL Server 6.x
[svrname]
svrname=data
[database]
database=cmis
[LogPass]
LogPass=sa
[LogId]
LogId=sa
[DBParm]
DBParm="PacketSize = 2000000000"

*/

String code,dbms,svrname,database,logpass,logid,DBParm

code= ProfileString("db.ini", "code", "code", "" )
dbms= ProfileString("db.ini", "dbms", "dbms", "" )
svrname = ProfileString("db.ini", "svrname", "svrname", "" )
database = ProfileString( "db.ini", "database", "database", "" )
logpass = ProfileString( "db.ini", "LogPass", "LogPass", "" )
logid = ProfileString( "db.ini", "LogId", "LogId", "" )
DBParm = ProfileString( "db.ini", "DBParm", "DBParm", "" )

sqlca.DBMS = dbms
sqlca.ServerName = svrname
sqlca.Database= database
sqlca.LogPass= logpass
sqlca.LogId= logid
sqlca.DBParm= DBParm
------解决方案--------------------
楼上顶一下
在应用中写
String code,dbms,svrname,database,logpass,logid,DBParm 

code= ProfileString("db.ini", "code", "code", "" ) 
dbms= ProfileString("db.ini", "dbms", "dbms", "" ) 
svrname = ProfileString("db.ini", "svrname", "svrname", "" ) 
database = ProfileString( "db.ini", "database", "database", "" ) 
logpass = ProfileString( "db.ini", "LogPass", "LogPass", "" ) 
logid = ProfileString( "db.ini", "LogId", "LogId", "" ) 
DBParm = ProfileString( "db.ini", "DBParm", "DBParm", "" ) 

sqlca.DBMS = dbms 
sqlca.ServerName = svrname 
sqlca.Database= database 
sqlca.LogPass= logpass 
sqlca.LogId= logid 
sqlca.DBParm= DBParm 
 
 
  相关解决方案