ค้นหาเว็บไซต์

จะตรวจสอบการเชื่อมต่อ SQL Server จาก SharePoint ได้อย่างไร


ฉันจะตรวจสอบการเชื่อมต่อ SQL Server จากเซิร์ฟเวอร์ SharePoint อย่างรวดเร็วได้อย่างไร คุณสามารถใช้ Telnet ได้
telnet {SQL-Server-Name or IP} 1433

หาก SQL Server ของคุณฟังบนพอร์ตอื่น ให้เปลี่ยนพอร์ตเริ่มต้น 1433 ตามลำดับ

การใช้ PowerShell เพื่อทดสอบการเชื่อมต่อเซิร์ฟเวอร์ SQL:
คุณยังสามารถใช้ PowerShell เพื่อตรวจสอบว่า SharePoint สามารถเชื่อมต่อกับ SQL Server ได้หรือไม่:


(New-Object System.Net.Sockets.TCPClient("SQL-Server-Name",1433)).Connected 

สิ่งนี้จะบอกคุณว่า PORT เฉพาะนั้นเปิดอยู่บนเซิร์ฟเวอร์ที่กำหนดหรือไม่

ตรวจสอบการเชื่อมต่อเซิร์ฟเวอร์ SQL โดยสร้างการเชื่อมต่อ:

เรียกใช้สคริปต์ PowerShell นี้เพื่อทดสอบว่าคุณสามารถเชื่อมต่อกับ SQL Server ได้หรือไม่


Function Check-SQLServerConnection([string]$serverInstance)
{
    $connectionString = "Data Source={0};Integrated Security=true;Application Name=CheckSQLServer" -f $serverInstance;
    $sqlConn = new-object("Data.SqlClient.SQLConnection") $connectionString;

    Write-Host $connectionString

    try {
        $sqlConn.Open();
        $sqlConn.Close();
        Write-Host "Connected OK"-foregroundcolor white -backgroundcolor green
    }
    catch { 
        Write-Host $_ -foregroundcolor white -backgroundcolor red
    }
    finally { 
        $sqlConn.Dispose(); 
    }
}
 #Call the function with your SQL Server Machine Name
 Check-SQLServerConnection "SP13-SQL01" 

บทความที่เกี่ยวข้อง