0

I'm trying to make a program for entering / editing and deleting users in a MySQL database. The database is external.

I have tried to change SqlConnection several times

con = new SqlConnection ("Data Source = ip /; Initial Catalog = u181542750_arsob; Integrated Security = True");

Complete CODE PASTEBIN

private void button1_Click(object sender, EventArgs e)
{
    SqlConnection con = new SqlConnection("Data Source=sql34.main-hosting.eu;Initial Catalog=u181542750_arsob;Integrated Security=True");
    con.Open();
    cmd = new SqlCommand("INSERT INFO Archers (Nume,Prenume,Varsta,Sex,Categorie,E-mail,Telefon,CNP) VALUES (@Nume,@Prenume,@Varsta,@Sex,@Categorie,@E-mail,@Telefon,@CNP)", con);
    cmd.Parameters.AddWithValue("@Nume", textBox1.Text);
    cmd.Parameters.AddWithValue("@Prenume", textBox2.Text);
    cmd.Parameters.AddWithValue("@Varsta", textBox3.Text);
    cmd.Parameters.AddWithValue("@Sex", comboBox1.SelectedItem.ToString());
    cmd.Parameters.AddWithValue("@Categorie", comboBox2.SelectedItem.ToString());
    cmd.Parameters.AddWithValue("@E-mail", textBox4.Text);
    cmd.Parameters.AddWithValue("@Telefon", textBox5.Text);
    cmd.Parameters.AddWithValue("@CNP", textBox6.Text);
    cmd.ExecuteNonQuery();
}

System.Data.SqlClient.SqlException: '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)'

Win32Exception: The network path was not found

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108

1 Answers1

1

Ping to see if it is up

ping sql34.main-hosting.eu

Check that you can access

telnet 31.220.20.81 1433

If you cannot then you need to check if port is closed, there is antivirus that is blocking, Integrated Security (windows user) is not created on that server or it does not have permissions to access that db.

Margus
  • 19,694
  • 14
  • 55
  • 103
  • From the beginning, phpmyadmin had all the permissions set. It is a database of a hosting that I have and is created and the option for the '' remote database '' – SeraphisRo Jul 28 '19 at 19:02