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


The name of the database.
Returns the database object with the specified name. The SQL Server connection uses the Windows Authentication.
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.ArgumentNullExceptionThe database is null.
System.ArgumentExceptionThe database is an empty string.
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 2022 xSQL Software. All Rights Reserved.

Send Feedback