PDA

View Full Version : Please help me out



Babu_jee
11-03-2002, 12:18 AM
I am a new commer , i want to install SQL Server database on the user machine, can anyone help me out.. i really appriciate help...
Thankx

RGoncalves
11-04-2002, 04:59 AM
I don't understand your doubt..
You want to install SQL Server or to install a database for SQLServer??

If you want to install a database you want to create one or just copy and attach to SQLServer, and another question do you wnat to install in a machine that has SQLServer or not??

I have some install scripts that maybe can help you..

Babu_jee
11-04-2002, 05:27 AM
No actually,on the user Machine SQL server is already available, what i want to do is , i want to Create a New Database, and i want to Create some new tables in that database, with fields.

Yes ...also tell me how can we attatch the database with the help of InstallShield in SQL Server

with the help of InstallShield Developer....


i really appriciate.

RGoncalves
11-04-2002, 05:55 AM
export prototype AttachDatabase (STRING ,STRING ,STRING ,STRING, STRING);
export prototype DetachDatabase(STRING, STRING, STRING, STRING);
export prototype StartSQLServer(STRING, STRING, STRING);
export prototype CreateDataBase(STRING, STRING, STRING, STRING, STRING);
export prototype ExecuteSQLScript(STRING, STRING, STRING, STRING, STRING, STRING);


//--------------------------------------------------------------------------------//
function ExecuteSQLScript(szServer, szUser, szPassword, szDBName, szDirFileName, szFileName)

STRING szConnString, szSQLCommand, szTemp;

OBJECT oSQLServer, oADOConnection, oADOCommand;

NUMBER nFuncResult, nFileHandle, nLength;

begin

try

set oSQLServer = CreateObject("SQLDMO.SQLServer");

catch

return FAILED_CREATE_SQLDMO;

endcatch;

try

oSQLServer.Start( TRUE, szServer, szUser, szPassword);

catch

oSQLServer.Connect(szServer, szUser, szPassword);

endcatch;

//prepara a Connection String
szConnString = "driver={SQL Server};";

szConnString = szConnString + "server=" + szServer + ";";

szConnString = szConnString + "Uid=" + szUser + ";";

szConnString = szConnString + "pwd=" + szPassword + ";";

szConnString = szConnString + "database=" + szDBName;

//cria ADO Connection
set oADOConnection = CreateObject("ADODB.Connection");

oADOConnection.Open(szConnString);

//cria o ADO Command para executar o script

set oADOCommand = CreateObject("ADODB.Command");

oADOCommand.ActiveConnection = oADOConnection;

OpenFileMode (FILE_MODE_NORMAL);

// Open the file for editing.
OpenFile (nFileHandle, szDirFileName, szFileName);

szSQLCommand = "";

nFuncResult = -1;
// Get lines from the file into the list.
while (GetLine (nFileHandle, szTemp) = 0)

if nFuncResult < 0 then szSQLCommand = "";

endif;

szSQLCommand = szSQLCommand + " " + szTemp;

nLength = StrLengthChars(szTemp);

if (nLength != 0) then

if szTemp[nLength - 1] = ";" then

oADOCommand.CommandText = szSQLCommand;

try
oADOCommand.Execute;
catch
MessageBox("Error creating database.\n Erro executing SQL scripts.", SEVERE);
endcatch;

nFuncResult = -1;

else nFuncResult = 1;

endif;

endif;

endwhile;

// Close the file.
CloseFile (nFileHandle);

end;
//--------------------------------------------------------------------------------//




//--------------------------------------------------------------------------------//
function CreateDataBase(szServer, szUser, szPassword, szDBName, szFileName)

OBJECT oSQLServer, oDBFile, oDatabase, oFileGroup, oRegistry;

begin

try

set oSQLServer = CreateObject("SQLDMO.SQLServer");

catch

return FAILED_CREATE_SQLDMO;

endcatch;

try

oSQLServer.Start( TRUE, szServer, szUser, szPassword);

catch

oSQLServer.Connect(szServer, szUser, szPassword);

endcatch;

set oRegistry = oSQLServer.Registry;

set oDatabase = CreateObject("SQLDMO.Database");

oDatabase.Name = szDBName;

set oDBFile = CreateObject("SQLDMO.DBFile");

oDBFile.Name = szFileName;

oDBFile.PhysicalName = oRegistry.SQLDataRoot + "\\Data\\" + szFileName + ".mdf";

oDBFile.PrimaryFile = TRUE;

oDatabase.FileGroups("PRIMARY").DBFiles.Add (oDBFile);

try
oSQLServer.Databases.Add (oDatabase);
catch
MessageBox("Error creating database", SEVERE);
endcatch;

end;
//--------------------------------------------------------------------------------//



//--------------------------------------------------------------------------------//
function AttachDatabase(szServer, szUser, szPassword, szDBName, szDBFileName)

OBJECT oSQLServer;

begin

try

set oSQLServer = CreateObject("SQLDMO.SQLServer");

catch

return FAILED_CREATE_SQLDMO;

endcatch;

try

oSQLServer.Start( TRUE, szServer, szUser, szPassword);

catch

oSQLServer.Connect(szServer, szUser, szPassword);

endcatch;

try

oSQLServer.AttachDBWithSingleFile( szDBName , szDBFileName );

catch

return FAILED_TO_ATTACH;

endcatch;

oSQLServer = NOTHING;

return SUCCESS;

end;
//--------------------------------------------------------------------------------//



//--------------------------------------------------------------------------------//
function DetachDatabase(szServer, szUser, szPassword, szDBName)

OBJECT oSQLServer;

begin

try

set oSQLServer = CreateObject("SQLDMO.SQLServer");

catch

return FAILED_CREATE_SQLDMO;

endcatch;

try

oSQLServer.Start( TRUE, szServer, szUser, szPassword);

catch

oSQLServer.Connect(szServer, szUser, szPassword);

endcatch;

try

oSQLServer.DetachDB( szDBName , TRUE );

catch

return FAILED_TO_DETACH;

endcatch;

oSQLServer = NOTHING;

return SUCCESS;

end;
//--------------------------------------------------------------------------------//




//--------------------------------------------------------------------------------//
function StartSQLServer(szServer, szUser, szPassword)

OBJECT oSQLServer;

begin

try

set oSQLServer = CreateObject("SQLDMO.SQLServer");

catch

return FAILED_CREATE_SQLDMO;

endcatch;

try

oSQLServer.Name = "(local)";

oSQLServer.Start( FALSE);

catch

endcatch;

return SUCCESS;

end;
//--------------------------------------------------------------------------------//

Babu_jee
11-05-2002, 05:21 AM
Thankx friend,
I really appriciate your help, interms of providing the scripts,i don't know how i am going to use these scripts,but first i will consult the help file shipped with the installShield, if not then i will come to you....again. he he he he

I have one last question, and that is can i use Macromedia Flash Files, in the installer, to make the installer more flashy,,like text effects..etc...music,,etc....

waiting for ur reply anxiously

Thankx

RGoncalves
11-05-2002, 05:51 AM
About the flashy things, i know that we can insert objects in the dialogs, just don't know how, i post a question about this some time ago but no feedback :(

About the scripts ,if it's a basic msi project you must insert a custom action, and insert in the right sequence in your setup, if it's a standard just insert in your script in the right order, but see the helps files from the developer, it explains well..

See you..

Babu_jee
11-05-2002, 06:28 AM
Thanks Friend, i will first Read the Help file carefully then i will see what will happen, thankx for the great help...

Thankyou

Take care