第一 先connection 数据库 在database中 然后导出ini文件 然后修改下
然后使用application中定义 读取ini文件
String autocommit; String str_file = "BaseIni.ini"; if not FileExists(str_file) then MessageBox("错误","文件不存在"); return end if String db ; SQLCA.DBMS=ProfileString( str_file,"Database","DBMS","") db = SQLCA.DBMS SQLCA.Database=ProfileString(str_file,"Database","Database","") SQLCA.LogID=ProfileString(str_file,"Database","LogID","") SQLCA.LogPass=ProfileString(str_file,"Database","LogPassword","") SQLCA.DbParm=ProfileString(str_file,"Database","DbParm","") autocommit=profilestring(str_file,"Database","autocommit","") if autocommit = "true" then MessageBox("tishi",db); SQLCA.autocommit=true end if if autocommit = "false" then SQLCA.autocommit=false end if connect; if sqlca.sqlcode<>0 then MessageBox("提示","连接失败"+sqlca.sqlerrText); else MessageBox("提示","okedsd"); end if open(w_login)
------------
制作datawindow 你要在window的open时间输入如下代码才能使显示在数据库中的数据
long r
dw_2.settransobject(sqlca);
r=dw_2.retrieve( );
还有ini文件的代码
[Database] DBMS=OLE DB Database="DD" LogId="sa" LogPassword="" ServerName="2012-04182041" DBParm=PROVIDER='SQLOLEDB',DATASOURCE='2012-04182041',PROVIDERSTRING='database=DD' Prompt=FALSE AutoCommit=true
下面比较详细
string autocommit; string str = "ERP.ini"; if not fileExists(str) then messagebox("","文件不存在"); return end if string db_dbms; db_dbms=ProfileString(str,"database","dbms",""); SQLCA.dbms= db_dbms; messagebox("", db_dbms); string db_database; db_database=ProfileString(str,"database","database",""); SQLCA.database=db_database; messagebox("",db_database); string db_logid; db_logid=ProfileString(str,"database","logid",""); SQLCA.logid =db_logid; messagebox("",db_logid); string db_logpass; db_logid=ProfileString(str,"database","logpass",""); SQLCA.logpass =db_logpass; messagebox("",db_logpass); string db_parm; db_parm=ProfileString(str,"database","dbparm",""); SQLCA.dbparm =db_parm; messagebox("",db_parm); autocommit = ProfileString(str,"database","autocommit",""); messagebox("",autocommit); if autocommit="true" then SQLCA.autocommit=true; else SQLCA.autocommit=false; end if connect using SQLca; if SQLCA.sqlcode <> 0 then messagebox("",sqlca.sqlerrtext ); return; else Messagebox("","success"); end if