Home > database >  [with] everybody look at me this code is there a problem?
[with] everybody look at me this code is there a problem?

Time:10-03

The integer li_rc, li_filenum
String ls_dir ls_dbfile, ls_datasource ls_dbname, ls_config, ls_database
Boolean lb_exist
Ls_datasource=as_dbname
Ls_dbname=as_dbname
Ls_dir=GetCurrentdirectory ()
Ls_dbfile=ls_dir + '\' + ls_dbname + 'db'
Ls_config=ls_dir + "\ config ini"
Boolean lb_exeist
Lb_exist=FileExists (ls_dbfile)
If not lb_exist then
Messagebox (" prompt ", "in the current directory does not exist:" + ls_dbname + "db")
The halt
End the if
Lb_exist=FileExists (ls_config)
//whether the configuration file is
If lb_exist then
Li_rc=profileint (" config. Ini ", "start", "first", 0)
//if there is access to configuration files of the start of the first key
//if the key does not exist the assignment of 0
The else
Li_FileNum=FileOpen (ls_config LineMode! The Write! , Shared! , Append!)
FileWrite (li_FileNum, "[start] ~ r ~ n first=1")
Li_rc=1
//if there is no, then according to certain format to create a configuration file
End the if
If li_rc=1 then
//read the configuration file for the first time

If RegistrySet (" HKEY_LOCAL_MACHINE \ SOFTWARE \ ODBC \ ODBCINST INI \ "+" 8.0 "the Adaptive Server Anywhere," Driver ", RegString! , "dbodbc8. DLL)=1 then"
Messagebox (" prompt ", "data source registered success!" )
End the if
//register data
The else
RegistrySet (" HKEY_LOCAL_MACHINE \ SOFTWARE \ ODBC \ ODBCINST INI \ "+" 8.0 "the Adaptive Server Anywhere," Driver ", RegString! , "dbodbc8. DLL")
RegistrySet (" HKEY_LOCAL_MACHINE \ SOFTWARE \ ODBC \ ODBCINST INI \ ODBC Data Sources ", ls_datasource, RegString! 8.0 ", "the Adaptive Server Anywhere)
RegistrySet (" HKEY_LOCAL_MACHINE \ SOFTWARE \ ODBC \ ODBCINST INI \ "+ ls_datasource," Drive ", RegString! , "dbodbc8. DLL")
RegistrySet (" HKEY_LOCAL_MACHINE \ SOFTWARE \ ODBC \ ODBCINST INI \ "+ ls_datasource," PWD ", RegString! , "SQL")
RegistrySet (" HKEY_LOCAL_MACHINE \ SOFTWARE \ ODBC \ ODBCINST INI \ "+ ls_datasource," DataFile RegString! , ls_dbfile)
RegistrySet (" HKEY_LOCAL_MACHINE \ SOFTWARE \ ODBC \ ODBCINST INI \ "+ ls_datasource, AutoStop, RegString! , "Yes")
RegistrySet (" HKEY_LOCAL_MACHINE \ SOFTWARE \ ODBC \ ODBCINST INI \ "+ ls_datasource," Integrated ", RegString! , "No")
RegistrySet (" HKEY_LOCAL_MACHINE \ SOFTWARE \ ODBC \ ODBCINST INI \ "+ ls_datasource," DatabaseName ", RegString! , ls_dbname)
RegistrySet (" HKEY_LOCAL_MACHINE \ SOFTWARE \ ODBC \ ODBCINST INI \ "+ ls_datasource," Debug ", RegString! , "No")
RegistrySet (" HKEY_LOCAL_MACHINE \ SOFTWARE \ ODBC \ ODBCINST INI \ "+ ls_datasource," DisableMultiRowFetch RegString! , "No")
Setprofilestring (" config. Ini ", "start", "first" and "0")
//modify the configuration files of the initial value, and then no longer read the file
End the if

The SQLCA. DBMS="ODBC"
The SQLCA. The AutoCommit=False
The SQLCA. DBParm="ConnectString='" +" DSN="+ ls_datasource +"; UID="+ as_uid +"; The PWD="+ as_pwd +" '"

//connect to the database
Connect using the sqlca;
If the sqlca. Sqlcode & lt;> 0 then
If li_rc=0 then
Setprofilestring (" config. Ini ", "start", "first", "1")
Messagebox (" prompt ", "please reconnect")
The else
Messagebox (" with the database connection failure ", "the discovery of the error when connecting to the database,")
End the if
Return false
The else
Return true
Disconnect;
End the if


Is looking for a data source code automatically, on your computer to run the program no problem, then change to another computer without pb is finished, the discovery of the error when connecting to the database...

CodePudding user response:

Didn't look, and see the

 global type f_odbcrefister from function_object 
End type

Forward as
Global function integer f_odbcregister ()
End as

Global function integer f_odbcregister (); Ls_driver string ls_sys [], [], st_driver, st_path, st_odbcdsn
String ls_me
The integer li_rtn

Ls_me="JNJJC"

//83463643 M

Ls_sys [1]="HKEY_LOCAL_MACHINE \ Software \ ODBC \ ODBCINST INI \ Microsoft Access Driver (*. MDB)"
Ls_sys [2]="HKEY_CURRENT_USER \ Software " + ls_me + "\ \ Sue road highway traffic management system"
Ls_sys [3]="HKEY_CURRENT_USER \ Software \ ODBC \ ODBC.ini \ ODBC Data Sources,"
Ls_sys [4]="HKEY_CURRENT_USER \ Software \ ODBC \ ODBC.ini"

Li_rtn=RegistryGet (ls_sys [1], "Driver", RegString! , st_driver)

IF li_rtn=1 THEN
Messagebox (" error ", "not installed Microsoft Access Driver (*. MDB)!" And information! , ok!
//RETURN
END the IF

Li_rtn=RegistryGet (ls_sys [2], "Path", RegString! , st_path)

IF li_rtn=1 THEN
Messagebox (" error ", "read the installation path error!" And information! , ok!
RETURN 0
END the IF

Li_rtn=RegistryGet (ls_sys [3], "SLT RegString! , st_odbcdsn)

IF (li_rtn=1 and st_odbcdsn='Microsoft Access Driver (*. MDB)') THEN
//messagebox (" error ", "read the installation path error OK!" And information! , ok!
RETURN 1
END the IF

String envfile ls_source [], ls_drivepath, ls_temp

The integer I

Ls_source [1]="SLT"
Ls_source [2]="yes"
Ls_source [3]=st_path + "" + "data \ road_database MDB"
Ls_source [4]='MS Access; '


Ls_source li_rtn=RegistrySet (ls_sys [3], [1], RegString! , "Microsoft Access Driver (*. MDB)")
IF li_rtn=1 THEN
Messagebox (" error ", "write reading system files or registry error!" And information! , ok!
RETURN 0
END the IF

Ls_sys [4]=ls_sys [4] + "" + ls_source [1]
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related