xSQL Schema Compare SDK version 9.5 for SQL Server
GetDatabase(String) Method
Example 


The name of the database.
Returns the database object with the specified name.
Syntax
'Declaration
 
Public Overloads Function GetDatabase( _
   ByVal dbName As System.String _
) As SqlDatabase
public SqlDatabase GetDatabase( 
   System.string dbName
)
public: SqlDatabase* GetDatabase( 
   System.string* dbName
) 

Parameters

dbName
The name of the database.

Return Value

A SqlDatabase database with the specified name.
Exceptions
ExceptionDescription
System.ArgumentExceptionThe name of the database is empty or null.
SchemaExceptionThe database is not found.
Remarks
The SqlDatabase class cannot be instantiated directly. Use this method to create a database object.
Example
The following example demonstrates how to create a database object:
using xSQL.Schema.Core;
using xSQL.Schema.SqlServer;
using xSQL.SchemaCompare.SqlServer;
            
namespace xSQL.Sdk.SchemaCompare.Samples
{
    class Test
    {
        public static void CreateDatabase()
        {
            SqlServer server;
            SqlDatabase database;
            
            //--initialize the SQL Server object 
            //--this constructor uses Windows authentication to establish the connection
            server = new SqlServer(@"(local)");
            
            //--create the database object for AdventureWorks
            database = server.GetDatabase("AdventureWorks");
            
        }
    }
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

SqlServer Class
SqlServer Members
Overload List

 

 


┬ęCopyright 2018 xSQL Software. All Rights Reserved.

Send Feedback