Options

GetDatabases missing

aperregatturvaperregatturv Posts: 67
Hi

Currently, I am using SQL Tool kit 6 which has the following code.

RedGate.SQL.Shared.SQLServer.GetDatabases(s, false, UID, PWD, true);
to retrieve all the databases.

Now, I am looking for this code in SDK 7 and unable to find.

Please let me know where i can find this.

Thanks

Comments

  • Options
    Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hi,

    I'm not sure that the SQLServer class is meant to be public, but I can tell you that it has moved to the RedGate.Shared.SQL.Server namespace. Quite a lot of RedGate.SQL.Shared has been shuffled around into different namespaces, so the next time you run into this problem, you may want to use Visual Studio's Object Explorer to search for the particular class you're looking for and find out where it's moved to.
  • Options
    Brian,

    Thanks for the reply. I already checked all the assemblies in the object Explorer before posting this.

    This is what i see in SDK 7
    RedGate.Shared.SQL.Server
    SQLServerDiscoveryExecption
    Base Types
    Exception
    ISerializable.

    Please check again. I use that code in lot of places where database list is populated and I don't want to rewrite all over again. I hope you understand the difficulties what we face.

    Thanks

    Arun
  • Options
    Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hi Arun,

    Ah I see. I don't think the GetDatabases method is static as in your example. I've got...
    try
                    {
                        if (checkBox1.Checked)
                            sqlServer = new SQLServer(true, comboBox2.Text, null, null);
                        else
                        {
                            // If SqlServer instance can't be initialized
                            // try, try again with SQL authentication
                            SqlAuthentication a = new SqlAuthentication(comboBox2.Text);
                            a.PasswordUpdate += new PasswordEventHandler(a_PasswordUpdate);
                            a.ShowDialog();
                        }
                    }
                    catch (Exception)
                    {
                        // Could not Connect -- try SQL auth
                        SqlAuthentication a = new SqlAuthentication(comboBox2.Text);
                        a.PasswordUpdate += new PasswordEventHandler(a_PasswordUpdate);
                        a.ShowDialog();
                    }
                    try 
                    {
                    comboBox1.DataSource = sqlServer.GetDatabases(true);
                    }
                    catch (System.Data.SqlClient.SqlException){}
    
Sign In or Register to comment.