SQL server2000+DELPHI5.0安装制作(10分)

  • 主题发起人 主题发起人 tianxing78
  • 开始时间 开始时间
T

tianxing78

Unregistered / Unconfirmed
GUEST, unregistred user!
请大家讨论一下关于SQL server2000+DELPHI5.0做的软件如何做安装程序啊?(在SQL SERVER2000中既有表也有存储过程)
 
将delphi制作的后台程序做成安装程序!可以用自带的制作安装程序,也可以用Wise Installation System 9.1简体中文版软件制作全中文界面的安装程序!
再将SQL SERVER中的数据表和存储过程做成脚本,然后在SQL Server中建立好数据库,设置好用户名和密码,执行脚本!
 
我想让用户自己自己安装SQL SERVER2000然后执行安装程序时,自动产生我所需要的库、以及库中的对象(表和存储过程),是在DELPHI中用语句自己一句句的写吗?在安装库时用户是要设置自己的用户名和密码的,我如何获取?还是采用让用户在第一次运行该软件时,自己输入用户名和密码?
 
可以将delphi做的程序作成安装程序,将调试后的sql server 库备份出来(如果是用ado连的,需要在注册表中加一键值),用户安装完sql后还原库即可。至于用户名和密码亦可将其写入库中,作一窗体,初始密码告诉用户后,用户可自己加入或删除、修改用户名或密码。
 
如何在DELPHI中修改SQL SERVER2000用户名、密码(像默认的sa)
 
我插一句嘴,要不要带上什么别的dll
 
谁能给个示例,简单点的也可以。
 
看来这类安装的确是有点问题,欢迎大家前来讨论!
 
分太少!
在你的开发计算机上,停止SQL Server 2000,将.mdf和.ldf文件
打包在安装程序,安装后,运行自己的代码安装这两个文件即可。
说明:fName: SQL Server 2000中安装的文件名,如果你的文件
为lll.mdf和lll_log.ldf, 则fName为lll。
procedure TInstallDbForm.OkBtnClick(Sender: TObject);
var
fName: String;
begin
fName := dName.Text;
try
ADOConnection1.Connected := True;
adodataset1.CommandText:='select db_id(''' + edDbName.Text + ''')';//数据库是否已经安装
adodataset1.Active:=true;
if adodataset1.Fields[0].AsInteger = 0 then
begin
adodataset1.Active:=false;
//将数据库安装上去.
ADOCommand1.CommandText :=
'sp_attach_db ''' + edDbName.Text + ''' , ' + '''' + dName.Text + ''' , ' + '''' + dLog.Text + '''';
ADOCommand1.Execute;
Info.Caption := '安装成功!请关闭窗口。';
end else
begin
Info.Font.Color := clRed;
Info.Caption := '数据库 ' + edDBName.Text + ' 已存在!';
end;
except
ADOConnection.Connected:=false;
adodataset1.Active:=false;
end;
end;
 
可以用sql-dmo来做数据库安装程序。用调用dll的方法在InstallShield中实现数据库的安装。
 
这是我用installshield 6.22做的一个安装的脚本 希望有帮助
包括了写注注册表(用户名)
////////////////////////////////////////////////////////////////////////////////
//
// File Name: Setup.rul
//
// Description: InstallShield script
//
// Comments: This script was generated based on the selections you made in
// the Project Wizard. Refer to the help topic entitled "Modify
// the script that the Project Wizard generates" for information
// on possible next steps.
//
////////////////////////////////////////////////////////////////////////////////

// Include header files

#include "ifx.h"

////////////////////// string defines ////////////////////////////
//////////////////// installation declarations ///////////////////
// ----- DLL function prototypes -----
// your DLL function prototypes
// ---- script function prototypes -----
// your script function prototypes
prototype SetupFolders();
prototype Pdkey(STRING);
prototype SetupRegistry();
// your global variables
STRING szmserial1,szmserial2,szmserial3,szmserial4,szmserial5;
//////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: OnFirstUIBefore
//
// EVENT: FirstUIBefore event is sent when installation is run for the first
// time on given machine. In the handler installation usually displays
// UI allowing end user to specify installation parameters. After this
// function returns, ComponentTransferData is called to perform file
// transfer.
//
///////////////////////////////////////////////////////////////////////////////
function OnFirstUIBefore()
number nResult,nSetupType;
string szTitle, szMsg;
string szLicenseFile, szQuestion;
string szName, szCompany, szSerial;
string szFile;
string szTargetPath;
string szDir;
string szComponents, szTargetdir;
number nLevel;
LIST listStartCopy;
LIST list;

number nvSize,rc;
begin

// TOdo
: if you want to enable background, window title, and caption bar title
// SetTitle( @TITLE_MAIN, 24, WHITE );

// SetTitle( @TITLE_CAPTIONBAR, 0, BACKGROUNDCAPTION );

// Enable( FULLWINDOWMODE );
// Enable( BACKGROUND );
// SetColor(BACKGROUND,RGB (0, 128, 128));

nSetupType = TYPICAL;
TARGETDIR = PROGRAMFILES ^@COMPANY_NAME ^@PRODUCT_NAME;
szDir = TARGETDIR;
Dlg_Start:
// begin
ning of dialogs label
Dlg_SdWelcome:
szTitle = "";
szMsg = "";
nResult = SdWelcome( szTitle, szMsg );
if (nResult = BACK) goto Dlg_Start;
Dlg_SdLicense:
szLicenseFile = SUPPORTDIR ^ "license.txt";
szTitle = "";
szMsg = "";
szQuestion = "";
nResult = SdLicense( szTitle, szMsg, szQuestion, szLicenseFile );
if (nResult = BACK) goto Dlg_SdWelcome;
Dlg_SdShowInfoList:
szFile = SUPPORTDIR ^ "infolist.txt";
list = ListCreate( STRINGLIST );
ListReadFromFile( list, szFile );
szTitle = "";
szMsg = "";
nResult = SdShowInfoList( szTitle, szMsg, list );
ListDestroy( list );
if (nResult = BACK) goto Dlg_SdLicense;

Dlg_SdRegisterUserEx:
szMsg = "";
szTitle = "";
nResult = SdRegisterUserEx( szTitle, szMsg, szName, szCompany, szSerial );
rc=Pdkey(szSerial);
if (( rc!=1) &&
(nResult != BACK)) then
MessageBox ( "序列号输入错误" , WARNING );
goto Dlg_SdRegisterUserEx;
else
if (nResult = BACK) then
goto Dlg_SdShowInfoList;
endif;
endif;
Dlg_SdAskDestPath:
szTitle = "";
szMsg = "";
nResult = SdAskDestPath( szTitle, szMsg, szDir, 0 );
TARGETDIR = szDir;
if (nResult = BACK) goto Dlg_SdRegisterUserEx;
Dlg_SetupType:
szTitle = "";
szMsg = "";
nResult = SetupType ( szTitle , szMsg , "" , nSetupType , 0 );
if (nResult = BACK) then
goto Dlg_SdAskDestPath;
else
nSetupType = nResult;
if (nSetupType != CUSTOM) then
szTargetPath = TARGETDIR;
nvSize = 0;
ComponentCompareSizeRequired(MEDIA,szTargetPath,nvSize);
if (nvSize != 0) then

MessageBox( szSdStr_NotEnoughSpace, WARNING );
goto Dlg_SetupType;
endif;
endif;

endif;
Dlg_SdComponentTree:
if ((nResult = BACK) &&
(nSetupType != CUSTOM)) goto Dlg_SetupType;
szTitle = "";
szMsg = "";
szTargetdir = TARGETDIR;
szComponents = "";
nLevel = 2;
if (nSetupType = CUSTOM) then
nResult = SdComponentTree(szTitle, szMsg, szTargetdir, szComponents, nLevel);
if (nResult = BACK) goto Dlg_SetupType;

endif;
Dlg_ObjDialogs:
nResult = ShowObjWizardPages(nResult);
if (nResult = BACK) goto Dlg_SdComponentTree;

Dlg_SdStartCopy:
szTitle = "";
szMsg = "";
listStartCopy = ListCreate( STRINGLIST );
//The following is an example of how to add a string(szName) to a list(listStartCopy).
//eg. ListAddString(listStartCopy,szName,AFTER);
//The following is an example of how to add a string(szName) to a list(listStartCopy).
ListAddString(listStartCopy,"你的选择如下:",AFTER);
ListAddString(listStartCopy,"/n",AFTER);
ListAddString(listStartCopy,"安装路径:"+TARGETDIR,AFTER);
ListAddString(listStartCopy,"/n",AFTER);
ListAddString(listStartCopy,"程序组名:"+SHELL_OBJECT_FOLDER,AFTER);
ListAddString(listStartCopy,"/n",AFTER);
if (nSetupType = CUSTOM) then
ListAddString(listStartCopy,"安装类型:"+"自定义",AFTER);
else
if (nSetupType = TYPICAL) then
ListAddString(listStartCopy,"安装类型:"+"典型",AFTER);
else
if (nSetupType = COMPACT) then
ListAddString(listStartCopy,"安装类型:"+"压缩",AFTER);
endif;
nResult = SdStartCopy( szTitle, szMsg, listStartCopy );
ListDestroy(listStartCopy);
if (nResult = BACK) goto Dlg_ObjDialogs;
// setup default status
SetStatusWindow(0, "");
Enable(STATUSEX);
StatusUpdate(ON, 100);
return 0;
end;

///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: OnMoving
//
// EVENT: Moving event is sent when file transfer is started as a result of
// ComponentTransferData call, before any file transfer operations
// are performed.
//
///////////////////////////////////////////////////////////////////////////////
function OnMoving()
string szAppPath,szUncmd;
int iPos;
begin
// Set LOGO Compliance Application Path
// TOdo
: if your application .exe is in a subfolder of TARGETDIR then
add subfolder
szAppPath = TARGETDIR;
RegDBSetItem(REGDB_APPPATH, szAppPath);
RegDBSetItem(REGDB_APPPATH_DEFAULT, szAppPath ^ @PRODUCT_KEY);
szUncmd = "UNINSTALL_CMD";
iPos = StrFind(UNINSTALL_STRING,szUncmd);
if iPos>0 then

UNINSTALL_STRING[iPos - 1]='/0';
UNINSTALL_STRING=UNINSTALL_STRING + ",LaunchSetup /"" + DISK1TARGET+"//setup.exe/"";
MaintenanceStart();
endif;
end;

//////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: Onbegin
//
// EVENT: begin
event is always sent as the first event during installation.
//
//////////////////////////////////////////////////////////////////////////////
function Onbegin
()
begin
szmserial1="0910-3256021-111";
szmserial2="0910-3254321-71301";
szmserial3="0910-3254321-71311";
szmserial4="0910-860023-111";
szmserial5="1111-111111-111";
end;

//////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: Pdkey(key)
//
// EVENT: Test SerialKey
//
//////////////////////////////////////////////////////////////////////////////
function Pdkey(key)
NUMBER rc;
begin
rc=0;
if key = szmserial1 then
rc=1;
goto rc_no;
endif;
if key = szmserial2 then
rc=1;
goto rc_no;
endif;
if key = szmserial3 then
rc=1;
goto rc_no;
endif;
if key = szmserial4 then
rc=1;
goto rc_no;
endif;
if key = szmserial5 then
rc=1;
endif;
rc_no:
return rc;
end;

//////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: SetupRegistry()
//
// EVENT: Regist key
//
//////////////////////////////////////////////////////////////////////////////
function SetupRegistry()
STRING szParent,szMsg;
begin
//注册系统信息
if (ComponentIsItemSelected(MEDIA,"账务系统") ) then
szParent="SOFTWARE//佳境科技//佳境音像管理系统";
RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE );
RegDBSetKeyValueEx ( szParent , "Installed" , REGDB_STRING , "True" , -1 );
RegDBSetKeyValueEx ( szParent , "server" , REGDB_STRING , "server" , -1 );
RegDBSetKeyValueEx ( szParent , "user" , REGDB_STRING , "sa" , -1 );
RegDBSetKeyValueEx ( szParent , "password" , REGDB_STRING , "" , -1 );
//注册SQLServer信息
RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE );
RegDBSetKeyValueEx ( "SOFTWARE//Microsoft//MSSQLServer//Client//DB-Lib//", "AutoAnsiToOem" , REGDB_STRING , "ON" , -1 );//不用改
RegDBSetKeyValueEx ( "SOFTWARE//Microsoft//MSSQLServer//Client//DB-Lib//", "UseIntlSettings" , REGDB_STRING , "ON" , -1 );//不用改
RegDBSetKeyValueEx ( "SOFTWARE//Microsoft//MSSQLServer//Client//ConnectTo//", "DSQUERY" , REGDB_STRING , "DBNMPNTW" , -1 );//不用改
RegDBSetKeyValueEx ( "SOFTWARE//Microsoft//MSSQLServer//Client//ConnectTo//", "storesvr" , REGDB_STRING , "DBMSSOCN,127.0.0.1,1433" , -1 );//不用改
//BDE信息
RegDBSetKeyValueEx ( "SOFTWARE//Borland//Database Engine//Settings//DRIVERS//MSSQL//INIT//" , "CONNECT TIMEOUT" , REGDB_STRING , "5" , -1 );//不用改
endif;
SdShowMsg(szMsg,FALSE);
return 0;
end;

// --- include script file section ---
///////////////////////////////////////////////////////////////////////////////
//
// Function: SetupFolders
//
// Purpose: This function creates all the folders and shortcuts for the
// setup. This includes program groups and items for Windows 3.1.
//
///////////////////////////////////////////////////////////////////////////////
function SetupFolders()
number nResult;
string szProgram,szUninstall,szResult;
begin
//卸载
szUninstall="C://Program Files//InstallShield Installation Information//{86BFF3ED-C576-473B-BB7A-5AF643F2286A}//Setup.exe";

LongPathToQuote (szUninstall, TRUE);

if(FindFile("C://Program Files//InstallShield Installation Information//{86BFF3ED-C576-473B-BB7A-5AF643F2286A}","Setup.exe",szResult)=0) then
AddFolderIcon (SHELL_OBJECT_FOLDER^"佳境音像管理系统","卸载 佳境音像处理系统",szUninstall,TARGETDIR^"MANAGER","", 0,"", REPLACE);
endif;
//系统应用
szProgram=TARGETDIR^"MANAGER//VCDLEASE.exe";
LongPathToQuote (szProgram, TRUE);

if(FindFile(TARGETDIR^"MANAGER","VCDLEASE.exe",szResult)=0) then
AddFolderIcon (SHELL_OBJECT_FOLDER^"佳境音像管理系统","佳境音像处理系统",szProgram,TARGETDIR^"MANAGER","", 0,"", REPLACE);
//桌面
AddFolderIcon(FOLDER_DESKTOP,"佳境音像处理系统",szProgram,TARGETDIR^"MANAGER","",0,"",REPLACE);
endif;
//帮助文件
szProgram=TARGETDIR^"MANAGER//HELP//VCDHELP.CHM";

LongPathToQuote (szProgram, TRUE);
if(FindFile(TARGETDIR^"MANAGER//HELP","VCDHELP.CHM",szResult)=0) then
AddFolderIcon (SHELL_OBJECT_FOLDER^"佳境音像管理系统","联机帮助",szProgram,TARGETDIR^"MANAGER//HELP","", 0,"", REPLACE);
endif;
//数据管理
szProgram=TARGETDIR^"DBMA//DBMA.exe";

LongPathToQuote (szProgram, TRUE);
if(FindFile(TARGETDIR^"DBMA","DBMA.exe",szResult)=0) then
AddFolderIcon (SHELL_OBJECT_FOLDER^"佳境音像管理系统","后台数据管理工具",szProgram,TARGETDIR^"DBMA","", 0,"", REPLACE);
endif;
return 0;
end;

//////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: OnMoved
//
// EVENT: Moved event is sent when file transfer started by ComponentTransferData call
// has finished. At this point all file transfer operations are completed
// except for batch self-registration which is performed immediately after this
// function returns. During uninstallation this event sent after uninstallation
// is completed. For that reason you should not modify system state in this
// event handler.
//
///////////////////////////////////////////////////////////////////////////////
function OnMoved()
STRING szMsg;
begin

szMsg="正在更新注册表......";
SdShowMsg(szMsg,TRUE);

SetupRegistry();
szMsg="正在创建快捷方式......";
SdShowMsg(szMsg,TRUE);
SetupFolders();
SdShowMsg(szMsg,FALSE);
return 0;
end;

 
如何制作脱离sql2000的安装程序,请给一简单示例,谢谢!!!
 
如果用SQL 2000,就必须装上 SQL 2000。
 
后退
顶部