Connecting to SQL Server from Vbnet

Hello,

I have folowing problem,
When connecting to SQL Server from Vbnet i get the message "There is a network error or an instance-specific error - The server is not found or is not accessible"
Connecting with the SQL server management works perfect.

mssql server works fine on my Pc,
But no connection possible to mssql server on my Laptop.

using:
Windows 10 Pro (10.0)
Microsoft SQL Server Express (64-bit)
C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL

Are there any possible settings that need to be adjusted?
Can anyone inform me how to fix this?

Thanks.
Marc.

When SQL Server is installed, for security reasons networking is not enabled.

Open SQL Server Configuration Manager and you'll find the TCP/IP settings.

Thanks for your answer,
TCP/IP configuration was correctly set to "Enabled"

I tried already almost everything with no results..
Connection string is also correct (tested on another pc)
this means finding where the error is.

the error i keep getting is:
A network error or instance-specific error occurred while connecting to SQL Server
The server is not found or is not accessible

Best regards,
Marc.

Application and database on same machine?

Yes

See some info on error log SQLserver...

Logging SQL Server messages in file 'C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\Log\ERRORLOG'.

Server process ID is 27060.
System Manufacturer: 'Dell Inc.', System Model: 'Precision 7680'.
Authentication mode is WINDOWS-ONLY.

SQL Server is attempting to register a Service Principal Name (SPN) for the SQL Server service. Kerberos authentication will not be possible until a SPN is registered for the SQL Server service. This is an informational message. No user action is required.

The SQL Server Network Interface library could not register the Service Principal Name (SPN) [ MSSQLSvc/Pc-Laptop ] for the SQL Server service. Windows return code: 0xffffffff, state: 63. Failure to register a SPN might cause integrated authentication to use NTLM instead of Kerberos. This is an informational message. Further action is only required if Kerberos authentication is required by authentication policies and if the SPN has not been manually registered.

Error: 18456, Severity: 14, State: 58.
Login failed for user 'Marc'. Reason: An attempt to login using SQL authentication failed. Server is configured for Integrated authentication only. [CLIENT: ]

Your are using a SQL user to login and the SQL instance is configured to allow only windows users to login. You can change the authentication to SQL server and windows authentication mode and try login again.
Right click->SQL instance properties

image

the authentication was already OK

now:
I activated user sa and have set a new password.
after done this the connection works perfect.

maybe i have to set new passwords to all the other users

or have i to delete the users an make as new users again?

++
Connection with normal username as Marc does not work, what i am doin wrong?

As per MSDN:

I don't know how enabling 'sa' user fixed the issue.

Thanks for your answer,

After changing authentication to SQL server then connection works...
see permissions settings
afbeelding

I am wondering this is the first time Windows authentication
does not work?

Best regards,
Marc.

You gave two different answers.

  1. Enabling sa login fixed the issue.
  2. Changing authentication mode fixed the issue.

As per my understanding, the authentication mode was set to windows initially and it worked after you changed it to SQL and windows authentication.

Thanks for your information.
Marc.

System.Data.SqlClient namespace. First, you define a connection string that includes the server name, database name, and authentication details. Then, you create a SqlConnection object with this string and open the connection.

For further learning, pursuing database SQL training can enhance your understanding of connecting to and managing SQL Server databases effectively. Visit this [link](https://itcourses.au/courses/sql-database-training/) for more information