Microsoft® SQL Server® 2012 Bible

(Ben Green) #1

790


Part V: Enterprise Data Management


$dbdsysfile.GrowthType = 'None'
$dbdsysfile.IsPrimaryFile = 'True'

# Create the file for the Application tables
$dbdappfile = new-object ('Microsoft.SqlServer.Management.Smo.DataFile')
($appfg, $applogname)
$appfg.Files.Add($dbdappfile)
$dbdappfile.FileName = $dbappfile
$dbdappfile.Size = [double](25.0 * 1024.0)
$dbdappfile.GrowthType = 'Percent'
$dbdappfile.Growth = 25.0
$dbdappfile.MaxSize = [double](100.0 * 1024.0)

# Create the file for the log
$dblfile = new-object ('Microsoft.SqlServer.Management.Smo.LogFile') ($db,
$loglogname)
$db.LogFiles.Add($dblfile)
$dblfile.FileName = $dblogfile
$dblfile.Size = [double](10.0 * 1024.0)
$dblfile.GrowthType = 'Percent'
$dblfile.Growth = 25.0

# Create the database
$db.Create()

# Set the default filegroup to AppFG
$appfg = $db.FileGroups['AppFG']
$appfg.IsDefault = $true
$appfg.Alter()
$db.Alter()

ADO.NET
ADO.NET consists of a set of object libraries that enable communication between client pro-
grams and the source of the data, in this case SQL Server. Two groups of objects are defi ned
within ADO.NET: a set of connected objects, which enables the client to communicate with
the server using an active connection, and a set of disconnected objects, which acts as an
offl ine data cache, enabling the client application to work with the data independently of
the server. These two groups of objects are listed here:

Connected objects are as follows:

■ (^) Connection object: A connection to the data source.
■ (^) Command object: Can represent a query against a database, a call to a stored
procedure, or a direct request to return the contents of a specifi c table.
LISTING 30-3 (continued)
c30.indd 790c30.indd 790 7/31/2012 9:46:23 AM7/31/2012 9:46:23 AM
http://www.it-ebooks.info

Free download pdf