Sql 2005, Db mirror, Client redirect

Pozdravljeni,

 Uspelo mi je uspešno postaviti mirroring baze. Odločil sem se za high availability opcijo (principal, mirror, witness). Na nivoju strežnikov zgleda, da poteka vse ok. Če ugasnem en strežnik, drug avtomatko prevzamo pravo vlogo.

 Zatakne pa se pri odjemalcih. S connection stringom "Data source=xxx.xxx.xxx.1;Failover Partner=xxx.xxx.xxx.2;initial catalog=pass2;integrated security=SSPI;packet size=4096" naj bi namreč povedal, da če datasource xxx.xxx.xxx.1 ni dosegljiv, da naj avtomatsko poskusi s povezavo na xxx.xxx.xxx.2. Če pa izklopim strežnik xxx.xxx.xxx.1, pa dobim spodnjo napako:

An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

Source Error:

Line 20:         cmd.Parameters.AddWithValue("@p2", DateTime.Now.ToString());;
Line 21:         cmd.Connection = conn;
Line 22:         conn.Open();
Line 23:         cmd.ExecuteNonQuery();
Line 24:         conn.Close();

Koda, s katero se pa povezujem, pa je:

using System;

System;

using System.Data.SqlClient;

System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page

partial class _Default : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

SqlConnection conn = new SqlConnection("Data source=xxx.xxx.xxx.1;Failover Partner=xxx.xxx.xxx.2;initial catalog=pass2;integrated security=SSPI;packet size=4096");

SqlCommand cmd = new SqlCommand("INSERT INTO Categories ( creation_date, name) values(@p1,@p2)");

cmd.Parameters.AddWithValue("@p1",DateTime.Now);

cmd.Parameters.AddWithValue("@p2", DateTime.Now.ToString());;

cmd.Connection = conn;

conn.Open();

cmd.ExecuteNonQuery();

conn.Close();

}

}

cmd.Connection = conn;

conn.Open();

cmd.ExecuteNonQuery();

conn.Close();

}

}

cmd.Connection = conn;

conn.Open();

cmd.ExecuteNonQuery();

conn.Close();

}

}

A ima kdo kakšno idejo kje se skriva napaka?

 

lp,

 

Rok

Avtor: Ripp, objavljeno na portalu SloDug.si (Arhiv)

Leave a comment

Please note that we won't show your email to others, or use it for sending unwanted emails. We will only use it to render your Gravatar image and to validate you as a real person.

spirit1
spirit1 - sreda, 20. junij 2007

probaj protokol nastavit na tcp/ip in ne na named pipes.

Ripp
Ripp - sreda, 20. junij 2007

Še to, povezava na bazo na drug strežnik dela brez problema (če zamenjam xxx.xxx.xxx.1 z xxx.xxx.xxx.2);