Это мой код, предназначенный для подключения к серверу MySQL и получения некоторой информации:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
namespace test_MLDropCopy
{
class Program
{
static void Main(string[] args)
{
string connectionString = "server=xxxxx;uid=xxxxx;pwd=xxxxx";
SqlConnection mySqlConnection = new SqlConnection(connectionString);
string selectString = "select Symbol from today_positions.all_rttp where ServiceName like 'ML%' and ID = 137800";
SqlCommand mySqlCommand = mySqlConnection.CreateCommand();
mySqlConnection.Open();
mySqlCommand.CommandText = selectString;
SqlDataReader myReader = null;
myReader = mySqlCommand.ExecuteReader();
string Symbol = myReader["Symbol"].ToString();
Console.WriteLine(Symbol);
mySqlConnection.Close();
}
}
}
Однако я получаю эту ошибку:
Unhandled Exception: System.Data.SqlClient.SqlException: A network-related or in
stance-specific error occurred while establishing a connection to SQL Server. Th
e server was not found or was not accessible. Verify that the instance name is c
orrect and that SQL Server is configured to allow remote connections. (provider:
Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Я дважды проверил учетные данные, которые я использую. Есть ли проблема в моем коде, или проблема со стороны базы данных (офлайн, неадекватные разрешения и т.д.)?