我是 sql azure 的新手。现在我面临一个大问题,这是因为 SQL Azure 联合。在我的一个项目中,我想使用联邦。为此,我想从所有联邦中读取数据。如何检查服务器中的联合总数并从联合中读取数据?还有如何将数据插入联邦?目前我正在使用:
string strSQL = @"SELECT f.name, fmc.federation_id, fmc.member_id, fmc.range_low, fmc.range_high " +
"FROM sys.federations f " +
"JOIN sys.federation_member_distributions fmc " +
"ON f.federation_id=fmc.federation_id " +
"ORDER BY fmc.federation_id, fmc.range_low, fmc.range_high";
string strTableName = "federation_member_distributions";
try
{
using (SqlConnection connection = new SqlConnection(csb.ToString()))
{
connection.Open();
sbResults.AppendFormat("-- Open {0}\r\n\r\n", csb.ToString());
data = new DataSet();
data.Locale = System.Globalization.CultureInfo.InvariantCulture;
using (SqlCommand command = connection.CreateCommand())
{
// Connect to federation root or federation member
command.CommandText = "USE FEDERATION ROOT WITH RESET";
command.ExecuteNonQuery();
sbResults.AppendFormat("{0}\r\nGO\r\n", command.CommandText);
}
//Retrieve federation root metadata, and populate the data to the DataGridView control
SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(strSQL, connection);
sqlDataAdapter.Fill(data, strTableName);
sbResults.AppendFormat("{0}\r\nGO\r\n", strSQL);
}
}
catch (Exception ex)
{
}
但它不起作用