sqldata/sqlsncapi.cpp
// Set version of the connected database
Set version of the connected database
Set version of the connected database
void SqlSncApi::SetVersion()
{
	const char *query = "SELECT CAST(@@VERSION AS VARCHAR(300))";
	size_t col_count = 0;
	size_t allocated_rows = 0;
	int rows_fetched = 0; 
	size_t time_read = 0;
	SqlCol *cols = NULL;
	int rc = OpenCursor(query, 1, 0, &col_count, &allocated_rows, &rows_fetched, &cols, &time_read, true);
	if(rc >= 0 && cols != NULL && cols[0].ind != NULL && cols[0]._data != NULL)
	{
		SQLLEN len = (SQLLEN)cols[0].ind[0];
		if(len != -1)
		{
			const char *cur = cols[0]._data;
			int line = 1;
			for(int i = 0; i < len; i++)
			{
				if(cur[i] == '\n')
				{
					line++;
					continue;
				}
				if(line == 2 || line == 3 || cur[i] == '\r' || cur[i] == '\t')
					continue;
				_version += cur[i];
			}
		}
	}
	CloseCursor();
}
void SqlSncApi :: SetVersion ( ) { const char * query = " " ; size_t col_count = 0 ; size_t allocated_rows = 0 ; int rows_fetched = 0 ; size_t time_read = 0 ; SqlCol * cols = NULL ; int rc = OpenCursor ( query , 1 , 0 , & col_count , & allocated_rows , & rows_fetched , & cols , & time_read , true ) ; if ( rc >= 0 && cols != NULL && cols [ 0 ] . ind != NULL && cols [ 0 ] . _data != NULL ) { SQLLEN len = ( SQLLEN ) cols [ 0 ] . ind [ 0 ] ; if ( len != -1 ) { const char * cur = cols [ 0 ] . _data ; int line = 1 ; for ( int i = 0 ; i < len ; i ++ ) { if ( cur [ i ] == ' \n ' ) { line ++ ; continue ; } if ( line == 2 || line == 3 || cur [ i ] == ' \r ' || cur [ i ] == ' \t ' ) continue ; _version += cur [ i ] ; } } } CloseCursor ( ) ; }
Set version of the connected database
Set version of the connected database
// Includes full product name // Microsoft SQL Server 2008 R2 (RTM) - 10.50.1617.0 (Intel X86) Apr 22 2011 11:57:00 Copyright (c) Microsoft Corporation Express Edition with Advanced Services on Windows NT 6.1 <X86> (Build 7600: ) // Microsoft SQL Server 2014 (SP2) (KB3171021) - 12.0.5000.0 (X64) Jun 17 2016 19:14:09 Copyright (c) Microsoft Corporation	Express Edition (64-bit) on Windows NT 6.3 <X64> (Build 10586: ) // Open cursor  // Get the value // Skip 2nd and 3rd line containing release date and copyright