cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
UNeverNo
Level 6

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
Labels (1)
0 Kudos
(4) Replies
TheTraveler
Level 8

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
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]
0 Kudos
UNeverNo
Level 6

Is there no other way? I don't want to ship ADO...
0 Kudos
TheTraveler
Level 8

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...
0 Kudos
loyalp
Level 5

I get a couple of L8411 errors for the two functions when I try to compile. Do I need to include another .h file?
0 Kudos