如何使用C#获取可用的sql server实例(在LAN中)和版本(如" Enterprise Edition(64位)")名称的列表

时间:2016-10-21 11:41:51

标签: c# sql-server

我想使用C#获取可用的sql server实例(在LAN中)和版本(例如&#34; Enterprise Edition(64位)&#34;)名称的列表。我收到了诸如&#34;服务器名称&#34;,&#34;版本&#34;等信息。使用# login-callback.php $fb = new Facebook\Facebook([ 'app_id' => '1200538793346947', 'app_secret' => '3cf44820ffae5f16c8122174701a558f', 'default_graph_version' => 'v2.8', ]); // Use one of the helper classes to get a Facebook\Authentication\AccessToken entity. $helper = $fb->getRedirectLoginHelper(); // $helper = $fb->getJavaScriptHelper(); // $helper = $fb->getCanvasHelper(); // $helper = $fb->getPageTabHelper(); try { $accessToken = $helper->getAccessToken(); // Get the \Facebook\GraphNodes\GraphUser object for the current user. // If you provided a 'default_access_token', the '{access-token}' is optional. $response = $fb->get('/me?fields=email,name,birthday,gender', $accessToken); } catch(\Facebook\Exceptions\FacebookResponseException $e) { // When Graph returns an error echo 'Graph returned an error: ' . $e->getMessage(); exit; } catch(\Facebook\Exceptions\FacebookSDKException $e) { // When validation fails or other local issues echo 'Facebook SDK returned an error: ' . $e->getMessage(); exit; } $me = $response->getGraphUser(); echo 'Logged in as ' . $me->getName(). ' ' . $me->getId() . ' '. $me->getGender() . ' '. $me->getEmail() . '<br />'; print_r($me->getBirthday()); 类。但是无法获得&#34; Edition&#34;实例。

2 个答案:

答案 0 :(得分:0)

我认为不能使用该方法获取版本信息:

MSDN SqlDataSourceEnumerator

这是获取信息的Tsql。你可以遍历上面的实例并执行它:

SELECT SERVERPROPERTY('productversion') As SQLVersionNumber, 
  SERVERPROPERTY ('productlevel') As ServicePackLevel, 
  SERVERPROPERTY ('edition') As EditionInfo

答案 1 :(得分:0)

您需要获取与SQL Server的连接并使用此处列出的任何技术查询其版本;

https://www.mssqltips.com/sqlservertip/1140/how-to-tell-what-sql-server-version-you-are-running/