Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

SQL Scripts


2 replies to this topic

fdmourao

fdmourao
  • Members
  • 18 posts

Posted 26 January 2005 - 16:28

Hello again,
Is there a way to return values from an sql script?
My problem is simple: During installation I want to get some values from a table in the SQL Server DataBase. Is it possible to do such, just through the SQL Scripts view or I need to write code to access the DataBase and execute the query?

Thanx in advance.

fveum

fveum
  • Members
  • 1 posts

Posted 16 February 2005 - 12:43

I am not sure if you already have a solution for this problem, but here is some code:


set objSQL = GetDatabaseConnection(pInstallSettings,FALSE);
if objSQL!=NOTHING then
try
set result = objSQL.Execute("EXEC NET_PROCEDURE_DoSomething");
while (!result.Eof)
data1 = result("Value1").Value;
data2 = result("Value2").Value;
result.MoveNext;
endwhile;
catch
_LogIt ( Err.Number , "Something bad happen " + Err.Description );
endcatch;



function OBJECT GetDatabaseConnection(pInstallSettings,showWarning)
STRING databaseServer,sqlPassword,dbName, userName,svString;
OBJECT objSqlConn;
begin

databaseServer = pInstallSettings->DatabaseServer.SQLServerAddress;

userName = pInstallSettings->DatabaseServer.SQLServerUserName;
sqlPassword = pInstallSettings->DatabaseServer.SQLServerSAPassword;

dbName = pInstallSettings->DatabaseServer.Database.Name;
try
set objSqlConn = CreateObject("ADODB.Connection");
objSqlConn.CursorLocation = 3;
objSqlConn.Mode = 3;
objSqlConn.CommandTimeout = 0;
objSqlConn.ConnectionTimeout = 30;

objSqlConn.Open("Provider=sqloledb;server=" + databaseServer + ";database=" + dbName + ";uid=" + userName + ";Password=" + sqlPassword);
catch
if (showWarning) then
LoadStringFromStringTable ( " Message_NoSQLConnection", svString );
MessageBox ( svString+": " + Err.Description , WARNING );
endif;
set objSqlConn = NOTHING;
endcatch;

return objSqlConn;
end;


fdmourao

fdmourao
  • Members
  • 18 posts

Posted 18 February 2005 - 10:54

Hi there fveum,
I have already concluded that I needed to write code for it.
I have already done so.

Thanx anyway.
Dário