S
Skip9999999999
Guest
I have code to parse emails and now I want to place certain data into a SQL database. I can't connect to the database. I keep getting Error 26 which seems to say it can't find my SQLExpress 2017 server which is on my local machine. So I wrote a simpler test code to test everything I could think of.
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim MyConnection As SqlConnection
'Tryed the ./SQLEXPESS default instead of the Server's Name (DESKTOP-11TM25R); and move the actual database file to the root - neither made any differance. "Data Source=./SQLEXPRESS; AttachDbFilename=D:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\eCom_Email.mdf; Integrated Security=True; Connect Timeout=30; User Instance=True"
'./SQLEXPRESS
MyConnection = New SqlConnection("Data Source = DESKTOP-11TM25R; AttachDbFilename=D:\eCom_Email.mdf; Integrated Security=True; Connect Timeout=30; User Instance=True")
'open the connection
MyConnection.Open()
lblConState.Text = MyConnection.State.ToString
'close connection
MyConnection.Close()
lblConState.Text += MyConnection.State.ToString
End Sub
End Class
The actual error message is:
"Message=A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Source=.Net SqlClient Data Provider StackTrace: <Cannot evaluate the exception stack trace>"
Anyone have an idea of what I'm doing wrong? Thanks
Carl
Continue reading...
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim MyConnection As SqlConnection
'Tryed the ./SQLEXPESS default instead of the Server's Name (DESKTOP-11TM25R); and move the actual database file to the root - neither made any differance. "Data Source=./SQLEXPRESS; AttachDbFilename=D:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\eCom_Email.mdf; Integrated Security=True; Connect Timeout=30; User Instance=True"
'./SQLEXPRESS
MyConnection = New SqlConnection("Data Source = DESKTOP-11TM25R; AttachDbFilename=D:\eCom_Email.mdf; Integrated Security=True; Connect Timeout=30; User Instance=True")
'open the connection
MyConnection.Open()
lblConState.Text = MyConnection.State.ToString
'close connection
MyConnection.Close()
lblConState.Text += MyConnection.State.ToString
End Sub
End Class
The actual error message is:
"Message=A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Source=.Net SqlClient Data Provider StackTrace: <Cannot evaluate the exception stack trace>"
Anyone have an idea of what I'm doing wrong? Thanks
Carl
Continue reading...