亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Powershell訪問SQL Server數(shù)據(jù)庫代碼實(shí)例

 更新時(shí)間:2014年11月07日 09:28:09   投稿:junjie  
這篇文章主要介紹了Powershell訪問SQL Server數(shù)據(jù)庫代碼實(shí)例,本文直接給出代碼,使用時(shí)只需要替換數(shù)據(jù)庫配置參數(shù)即可,需要的朋友可以參考下

支持所有版本的SQLserver。

你是否需要連接數(shù)據(jù)庫?這里有一段代碼演示如何查詢和獲取SQL數(shù)據(jù),只需非常簡(jiǎn)單正確的配置你的賬戶信息、服務(wù)器地址及SQL語句就行:

復(fù)制代碼 代碼如下:

$Database                       = 'Name_Of_SQLDatabase'
$Server                         = '192.168.100.200'
$UserName                         = 'DatabaseUserName'
$Password                       = 'SecretPassword'
 
$SqlQuery                       = 'Select * FROM TestTable'
 
# Accessing Data Base
$SqlConnection                  = New-Object -TypeName System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Data Source=$Server;Initial Catalog=$Database;user id=$UserName;pwd=$Password"
$SqlCmd                         = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText             = $SqlQuery
$SqlCmd.Connection              = $SqlConnection
$SqlAdapter                     = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand       = $SqlCmd
$set                            = New-Object data.dataset
 
# Filling Dataset
$SqlAdapter.Fill($set)
 
# Consuming Data
$Path = "$env:temp\report.hta"
$set.Tables[0] | ConvertTo-Html | Out-File -FilePath $Path
 
Invoke-Item -Path $Path 

相關(guān)文章

最新評(píng)論