Can Write To Azure SQL Database, Cannot Read

Josh Barth 0 Reputation points
2024-10-03T02:53:54.4333333+00:00

I am so confused on this one.

I have been able to write to my Azure Database for MySQL flexible server using python, it works no problem, it uploads my data and I can see the new tables and I can actually read those tables on my wix website no problem.

I just attempted to read from the database and it will NOT read from the database. I have tried to use Azure Data Studio as PowerBi was would also NOT connect and Azure Data Studio gave me the following error:

"Microsoft.Data.SqlClient.SqlException (0x80131904): 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) ---> System.ComponentModel.Win32Exception (53): The network path was not found. at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at Microsoft.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnectionString connectionOptions, Boolean withFailover) at Microsoft.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) at Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) at Microsoft.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) at Microsoft.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken, DbConnectionPool pool) at Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) at Microsoft.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) at Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) at Microsoft.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) at Microsoft.Data.ProviderBase.DbConnectionPool.WaitForPendingOpen() --- End of stack trace from previous location --- at Microsoft.Data.SqlClient.SqlRetryLogicProvider.ExecuteAsync(Object sender, Func1 function, CancellationToken cancellationToken) at Microsoft.Data.SqlClient.SqlRetryLogicProvider.ExecuteAsync(Object sender, Func1 function, CancellationToken cancellationToken) at Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection.ReliableSqlConnection.<>c__DisplayClass31_0.<

EDIT:

I was able to get my python code to read from the database.

I am now just super confused on why Azure Data Studio will not connect? I would really like to view my table structure in the GUI.

MySQL Workbench connected on my first try, no clue what is going on with Powerbi or Azure Data Studio but I shall uninstall both of those fraud programs.

Azure Database for MySQL
Azure Database for MySQL
An Azure managed MySQL database service for app development and deployment.
934 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Mahesh Kurva 3,500 Reputation points Microsoft External Staff
    2024-10-03T18:13:34.63+00:00

    Hi @Josh Barth,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    The error message you're seeing is related to SQL Server, not MySQL. The Microsoft.Data.SqlClient namespace is specific to SQL Server, and the error message is indicating that it's trying to connect to a SQL Server instance

    This is likely because Azure Data Studio is trying to use the wrong connection type or settings for your MySQL database. MySQL and SQL Server are two different database management systems, and they have different connection protocols and settings.

    "Microsoft.Data.SqlClient.SqlException (0x80131904): 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) ---> System.ComponentModel.Win32Exception (53): The network path was not found.

    Here are the troubleshooting steps that might help you:

    • Make sure the SQL Server instance is running. You can check the status of the SQL Server instance in the SQL Server Configuration Manager.
    • Make sure the SQL Server Browser service is running. This service helps in connecting to named instances.
    • Make sure the firewall is not blocking the connection. If you are connecting to a remote SQL Server instance, you might need to add an exception for the SQL Server port (1433 by default) in the firewall.
    • The error message indicates that the network path was not found. Check if the server name and instance name are correct and accessible from your network.
    • Double-check your connection string for any typos or incorrect parameters.
    • Make sure SQL Server is configured to allow remote connections.
    • Test the server connectivity using ping and telnet commands to ensure the server is reachable and listening on the correct port.

    For detailed information, please refer the document: https://learn.microsoft.com/en-us/troubleshoot/sql/database-engine/connect/network-related-or-instance-specific-error-occurred-while-establishing-connection

    Hope this helps. Do let us know if you any further queries.

    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.