Home > database >  Pb to generate an executable file to add the SQL database
Pb to generate an executable file to add the SQL database

Time:09-17

Pb generated EXE files, can generate, can run, but was unable to connect to the database, what I use is SQL2005, generated EXE, in those steps, I don't see the option to set up the database, seek expert advice, how to add database, best can have the detailed steps, first thanked!!!!!

CodePudding user response:

Try to get a green version of the database, to the top!

CodePudding user response:

Write a configuration file, using the configuration file associated database.

CodePudding user response:

refer to the second floor xuam response:
write a configuration file, using the configuration file associated database.

Want to program is running, to ensure that the database can normal visit,
The original poster is to want to PB generated EXE files are packaged in the database? This is not possible,
Database requires a separate configuration,

CodePudding user response:

I want to wrap up the database into, is now is not, can you tell me where is the configuration?

CodePudding user response:

Possible, the database under the tools menu add profile

CodePudding user response:

Whether to put. MDF and. LDF files in a directory

CodePudding user response:

Add a DLL file

CodePudding user response:

Through the recovery of the database backup, backup library into empty. BAK files, and then at the client runtime recovery can directly, and the configuration files and create together, I do it, I hope it can help you!
1, in the query analyzer, using SQL Server restore filelistonly command to view the logical file name BAK
Restore filelistonly from disk="d:/isystem bak '
View next to the logical file, modify the CODE to recover the database part, the logical name of the file to backup your database,
2, the window

3, the data window (exteral)

4, the specific CODE
 
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* description: the create database
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
String ls_execsql ls_serverinfo, ls_username ls_pass, ls_repass, ls_dbname, ls_path, ls_null
The integer li_ret
Long ll_status, ll_current_row

Ls_path=gs_currentpath + "\ isystem bak"
//create the database directory
If directoryexists (gs_currentpath + "\ dbname")=false then
Createdirectory (gs_currentpath + "\ dbname")
End the if

Dw_1. Accepttext ()
Ll_current_row=dw_1. Getrow ()
Ls_serverinfo=dw_1. Getitemstring (ll_current_row, "serverinfo")
If ls_serverinfo='or isnull (ls_serverinfo)=true then
Messagebox (message: ""," please fill in the server name or IP!" )
Dw_1. Setfocus ()
Dw_1. Setcolumn (1)
Return
End the if
Ls_username=dw_1. Getitemstring (ll_current_row, "dbuser")
Ls_pass=trim (dw_1 getitemstring (ll_current_row, "dbpass"))
If ls_pass='or isnull (ls_pass)=true then
Messagebox (message: ""," please fill out the database password!" )
Dw_1. Setfocus ()
Dw_1. Setcolumn (3)
Return
End the if
Ls_repass=trim (dw_1 getitemstring (ll_current_row, "redbpass"))
If ls_repass='or isnull (ls_repass)=true then
Messagebox (the 'message:', please fill out the repeat password! "" )
Dw_1. Setfocus ()
Dw_1. Setcolumn (4)
Return
End the if
If ls_pass & lt;> Ls_repass then
Messagebox (' message: ', 'two login password is not consistent, please check! ')
Setnull (ls_null)
Dw_1. Object. Dbpass. Primary. Current=ls_null
Dw_1. Object. Redbpass. Primary. Current=ls_null
Dw_1. Setfocus ()
Dw_1. Setcolumn (3)
Return
End the if
Ls_dbname=dw_1. Getitemstring (ll_current_row, "dbname")

/* * * * * * * * * determine whether have installed SQL start * * * * * * * * */
Oleobject pbobject
Pbobject=create oleobject
Ll_status=pbobject. Connecttonewobject (" sqldmo. Essentially ")

If ll_status=0 then//connection success
Pbobject. Name=ls_serverinfo
Pbobject. Logintimeout=10
//connected to SQL server mode
Pbobject. Loginsecure=false
Li_ret=pbobject. Status
If li_ret & lt;> 1 then
Destroy (pbobject)
Messagebox (message: ""," SQL server does not start, "StopSign!)
Return
End the if
The else
Destroy (pbobject)
Messagebox (message: ""," SQL server not installed ", StopSign!)
Return
End the if

/* * * * * * * * * * * * * * * connect to the database * * * * * * * * * * * * */

The SQLCA. DBMS="OLE DB"
The SQLCA. LogPass=ls_pass
The SQLCA. LogId=ls_username
The SQLCA. The AutoCommit=true
The SQLCA. DBParm="PROVIDER='SQLOLEDB'," + & amp;
"The DATASOURCE='" + ls_serverinfo +", "+ & amp;
"PROVIDERSTRING='Database=master" + "' "

Connect using the sqlca;
If the sqlca. Sqlcode & lt;> 0 then
Messagebox (message: ""," database connection failed, please check the database login password is correct!" )
Return
End the if

/* * * * * * * * * * * through the device file restore database * * * * * * * * * * */

//create an empty library
Ls_execsql="create database" + ls_dbname
The execute immediate: ls_execsql;
If the sqlca. SQLCode=0 then
commit;
The else
The rollback.
End the if

//restore database
Ls_dbname ls_execsql="restore the database" + + "from disk='" + ls_path +"' with the replace, move ~ 'isystem_Data ~ to ~' "+ gs_currentpath +" \ dbname \ isystem_Data MDF ~ ', move ~ 'isystem_Log ~ to ~' "+ gs_currentpath +" \ dbname \ isystem_Log LDF ~ '"
The execute immediate: ls_execsql;

If the sqlca. Sqlcode=0 then
commit;
//delete the database file
If fileexists (ls_path)=true then
Filedelete (ls_path)
End the if
//modify the DBMS. Ini file, if there is no this file is created and then directly write
If fileexists (gs_currentpath + "\ DBMS ini")=true then
Setprofilestring (gs_currentpath + "\ DBMS ini", "database", "dbname", ls_dbname)
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related