我在ASP .NET工作,我需要做一些事情:
我从这开始:
public static bool PublicationExists(string server)
{
string finalConnString = Properties.Settings.Default.rawConnectionString.Replace("<<DATA_SOURCE>>", server).Replace("<<INITIAL_CATALOG>>", "tempdb");
using (var conn = new SqlConnection(finalConnString))
{
using (var cmd = new SqlCommand("what is the query to check whether a publication exists?", conn))
{
conn.Open();
cmd.ExecuteNonQuery();
using (var da = new SqlDataAdapter(cmd))
{
using (var ds = new DataSet())
{
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
return true;
}
return false;
}
}
}
}
}
现在...
If (PublicationExists(server) == true)
{
//I want to delete the publication along with everything associated with it.
}
我将如何做到这一点?