0

I just try to connect on a SqlDatabse(running with Xampp) with a IP, but when i start to connect a Error shows up:

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: TCP Provider, error: 40 - Could not open a connection to SQL Server)\nA 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: TCP Provider, error: 40 - Could not open a connection to SQL Server)

here the Code:

string connetionString;
SqlConnection cnn;
connetionString = @"Data Source=(IP from Laptop with XAMPP);Initial Catalog=hoffmann;User ID=root;";
cnn = new SqlConnection(connetionString);
cnn.Open();
cnn.Close();
stuartd
  • 70,509
  • 14
  • 132
  • 163
  • 2
    Xampp installs mysql or mariaDb, not SQL Server. Do you understand the difference? – ADyson Aug 30 '20 at 15:47
  • @ADyson not really, but i need to change the my Code or what? –  Aug 30 '20 at 15:50
  • Well they are different products, different kinds of database system. So yes you need to change your code. To connect to mysql you have to use the c# code designed for mysql. See https://stackoverflow.com/questions/21618015/how-to-connect-to-mysql-database – ADyson Aug 30 '20 at 15:51
  • @ADyson okey. I'll give it a try, thank you –  Aug 30 '20 at 15:54
  • 2
    P.s. if you're coding in c# I don't know why you installed xampp - that is aimed at PHP developers usually. It would have been enough to simply install MySQL by itself – ADyson Aug 30 '20 at 16:04
  • Have you pinged the server to see if it is online? – Don Aug 30 '20 at 16:42
  • @Don That's not relevant. I think you've missed the important details in the question, and the subsequent comments. – ADyson Aug 30 '20 at 18:19

0 Answers0