Reference:
#連線資料庫
$serverName = "SQL01"
$databaseName = "wiside"
$tableName = "dbo.raw_data"
$uid = 'sa'
$pwd = 'mypassword'
$Connection = New-Object System.Data.SQLClient.SQLConnection
$Connection.ConnectionString = "server='$serverName';database='$databaseName';User ID = $uid; Password = $pwd;"
$Connection.Open()
$Command = New-Object System.Data.SQLClient.SQLCommand
$Command.Connection = $Connection
$serverName = "SQL01"
$databaseName = "wiside"
$tableName = "dbo.raw_data"
$uid = 'sa'
$pwd = 'mypassword'
$Connection = New-Object System.Data.SQLClient.SQLConnection
$Connection.ConnectionString = "server='$serverName';database='$databaseName';User ID = $uid; Password = $pwd;"
$Connection.Open()
$Command = New-Object System.Data.SQLClient.SQLCommand
$Command.Connection = $Connection
$insertquery="INSERT INTO $tableName ([ID],[mac],[vendor],[datetime]) VALUES ('$ID','$mac','$vendor','$datetime')"
$Command.CommandText = $insertquery
$Command.ExecuteNonQuery()
$Connection.Close();
沒有留言:
張貼留言