This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Detect SQL server version?
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 07, 2008
09:59 AM
Detect SQL server version?
I need to deliver a huge database to a server that can be installed locally or via LAN.
So I first of all need to ask the user, if a server is found in LAN, if he wants to install it there. Therefore I need to know, if it's a 2000 or 2005 SQL Server, because they use different BCP.exe (from M$) to pump the data into the database.
The progress of asking the user is made in an Installscript project, which calls my MSI-project with the property IS_SQLSERVER_SERVER, so the name is also available there.
I now need a way to differ between these two server types to install the different BCP.exe
So I first of all need to ask the user, if a server is found in LAN, if he wants to install it there. Therefore I need to know, if it's a 2000 or 2005 SQL Server, because they use different BCP.exe (from M$) to pump the data into the database.
The progress of asking the user is made in an Installscript project, which calls my MSI-project with the property IS_SQLSERVER_SERVER, so the name is also available there.
I now need a way to differ between these two server types to install the different BCP.exe
(4) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 07, 2008
10:22 AM
You could try this in Install Shield script. This will connect to a SQL Server via ADO Objects and run a SQL script. This SQL script will query the database engine for what database engine it is.
.h File
.rul
[CODE]///////////////////////////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////////////////////////
function My_ADODB_GetSQLServerVersion(strVersion)
STRING strConnection;
STRING strProductVersion;
STRING strServicePack;
STRING strSoftwarePlatform;
begin
My_ADODB_BuildConnectionString(strConnection);
return My_ADODB_GetSQLServerVersionEX(strConnection,
strVersion,
strServicePack,
strSoftwarePlatform
);
end;
///////////////////////////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////////////////////////
function My_ADODB_GetSQLServerVersionEX(strConnectionString,
strProductVersion,
strServicePack,
strSoftwarePlatform
)
OBJECT objRecordSet;
BOOL bResult;
STRING strQry;
STRING strFieldName;
STRING strValue;
STRING strTemp;
STRING strError;
begin
bResult = FALSE;
m_strADOError = "";
strError = "";
strValue = "";
///////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////
strProductVersion = "";
strServicePack = "";
strSoftwarePlatform = "";
///////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////
strQry= "Select ServerProperty('ProductVersion') As ProductVersion, ";
strQry = strQry +" ServerProperty('ProductLevel' ) As ServicePack, ";
strQry = strQry +" @@Version As SoftwarePlatform";
///////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////
if My_ADODB_ConnectEX(strConnectionString) then
strValue = "";
try
set objRecordSet = m_objConnection.Execute(strQry);
strProductVersion = objRecordSet("ProductVersion" );
strServicePack = objRecordSet("ServicePack" );
strSoftwarePlatform = objRecordSet("SoftwarePlatform");
bResult = TRUE;
catch
NumToStr(strTemp, Err.Number);
strError = "An unhandled exception occurred...\n"+
"[Number]"+ strTemp +"\n"+
"[Source]"+ Err.Source +"\n"+
"[Description]"+ Err.Description;
endcatch;
set objRecordSet = NOTHING;
else
strError = m_strADOError;
endif;
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
if bResult then
m_nADO_ErrNumber = 0;
m_strADO_ErrSource = "";
m_strADO_ErrDescription = "";
endif;
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
return bResult;
end;[/CODE]
.h File
external prototype My_ADODB_GetSQLServerVersion(BYREF STRING);
external prototype My_ADODB_GetSQLServerVersionEX(BYVAL STRING, // strConnectionString
BYREF STRING, // strProductVersion
BYREF STRING, // strServicePack
BYREF STRING // strSoftwarePlatform
);
.rul
[CODE]///////////////////////////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////////////////////////
function My_ADODB_GetSQLServerVersion(strVersion)
STRING strConnection;
STRING strProductVersion;
STRING strServicePack;
STRING strSoftwarePlatform;
begin
My_ADODB_BuildConnectionString(strConnection);
return My_ADODB_GetSQLServerVersionEX(strConnection,
strVersion,
strServicePack,
strSoftwarePlatform
);
end;
///////////////////////////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////////////////////////
function My_ADODB_GetSQLServerVersionEX(strConnectionString,
strProductVersion,
strServicePack,
strSoftwarePlatform
)
OBJECT objRecordSet;
BOOL bResult;
STRING strQry;
STRING strFieldName;
STRING strValue;
STRING strTemp;
STRING strError;
begin
bResult = FALSE;
m_strADOError = "";
strError = "";
strValue = "";
///////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////
strProductVersion = "";
strServicePack = "";
strSoftwarePlatform = "";
///////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////
strQry= "Select ServerProperty('ProductVersion') As ProductVersion, ";
strQry = strQry +" ServerProperty('ProductLevel' ) As ServicePack, ";
strQry = strQry +" @@Version As SoftwarePlatform";
///////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////
if My_ADODB_ConnectEX(strConnectionString) then
strValue = "";
try
set objRecordSet = m_objConnection.Execute(strQry);
strProductVersion = objRecordSet("ProductVersion" );
strServicePack = objRecordSet("ServicePack" );
strSoftwarePlatform = objRecordSet("SoftwarePlatform");
bResult = TRUE;
catch
NumToStr(strTemp, Err.Number);
strError = "An unhandled exception occurred...\n"+
"[Number]"+ strTemp +"\n"+
"[Source]"+ Err.Source +"\n"+
"[Description]"+ Err.Description;
endcatch;
set objRecordSet = NOTHING;
else
strError = m_strADOError;
endif;
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
if bResult then
m_nADO_ErrNumber = 0;
m_strADO_ErrSource = "";
m_strADO_ErrDescription = "";
endif;
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
return bResult;
end;[/CODE]
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 08, 2008
10:24 AM
Is there no other way? I don't want to ship ADO...
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 08, 2008
11:23 AM
On any system I have installed, the ADO COM component was already there. I believe that ADO COM object is installed automatically on SQL Database Server.
Give it a try...
Give it a try...
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 16, 2008
04:08 PM
I get a couple of L8411 errors for the two functions when I try to compile. Do I need to include another .h file?