[英]Failing to connect remotely to sqlserver in vb.net
我面臨着遠程連接到 vb.net 中的 sqlserver 的挑戰。 我使用的是MSSql Server 2014 Express Edition,錯誤信息如下:
連接超時已過期。 嘗試使用登錄前握手確認時超時時間已過。 這可能是因為登錄前握手失敗或服務器無法及時響應。 嘗試連接到此服務器所花費的持續時間為 - [Pre-Login] 初始化 = 184; 握手=14923;
我的 Vb.Net 代碼如下:
Imports System.Data.SqlClient
Public Class Form1
Dim connection As New SqlConnection("Data Source=77.246.xx.xx,1433;Network Library=DBMSSOCN;Initial Catalog=company_info;User ID=CSPOS;Password=password1;")
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
connection.Open()
TextBox1.Text = "You have connected to sql server successfully!!"
TextBox1.ForeColor = Color.Green
connection.Close()
Catch ex As Exception
TextBox1.Text = ex.Message
TextBox1.ForeColor = Color.Red
End Try
End Sub
End Class
我被卡住了,我不知道如何處理它並使事情發揮作用。
將您的連接字符串更新為
Data Source=77.246.xx.xx,1433;Database=company_info;User ID=CSPOS;Password=password1;Persist Security Info=True
它在 VB.NET 中對我有用
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.