검색결과 리스트
글
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
I managed to interface Oracle and a GUI via powershell.
First, load the Oracle and the .NET assemblies
[void] [Reflection.Assembly]::LoadFile("C:\oracle\product\11.2.0\client_1\ODP.NET\bin\2.x\Oracle.DataAccess.dll")
[void] [Reflection.Assembly]::LoadWithPartialName("Drawing")
[void] [Reflection.Assembly]::LoadWithPartialName("Windows.Forms")
Now, let’s retrieve EMP in a powershell array. I hope one of my reader will advise me on a better way.
$connection=New-Object Oracle.DataAccess.Client.OracleConnection("Data Source=DB01; User Id=scott; password=tiger")
$connection.open()
$command=new-object Oracle.DataAccess.Client.OracleCommand("select ename from emp",$connection)
$reader = $command.ExecuteReader()
$a = @()
while ($reader.Read()) {
$a = $a + $reader.GetString(0)
}
$connection.close()
last, let’s create a simple window (a Form) with a list (a List box) where you can select an item with a doubleclick.
Initialize the list with the array from EMP
$form = New-Object Windows.Forms.Form
$form.Text = "Select employee !"
$form.Size = New-Object Drawing.Size(640,480)
$form.StartPosition = "CenterScreen"
$listbox = New-Object Windows.Forms.ListBox
$listbox.Location = New-Object Drawing.Point(10,10)
$listbox.Size = New-Object Drawing.Size(620,460)
$listbox.Items.AddRange($a)
$listbox.Add_DoubleClick({$form.Close();})
$form.Controls.Add($listbox)
$form.Topmost = $True
$form.Add_Shown({$form.Activate()})
[void] $form.ShowDialog()
Show the result (or use it in your powershell scripts)
PS> $listbox.SelectedItems[0]
SCOTT
Pretty cool! No compiler needed, directly run from the powershell prompt
출처 : http://laurentschneider.com/wordpress/2012/05/my-first-net-gui-in-powershell.html
First, load the Oracle and the .NET assemblies
[void] [Reflection.Assembly]::LoadFile("C:\oracle\product\11.2.0\client_1\ODP.NET\bin\2.x\Oracle.DataAccess.dll")
[void] [Reflection.Assembly]::LoadWithPartialName("Drawing")
[void] [Reflection.Assembly]::LoadWithPartialName("Windows.Forms")
Now, let’s retrieve EMP in a powershell array. I hope one of my reader will advise me on a better way.
$connection=New-Object Oracle.DataAccess.Client.OracleConnection("Data Source=DB01; User Id=scott; password=tiger")
$connection.open()
$command=new-object Oracle.DataAccess.Client.OracleCommand("select ename from emp",$connection)
$reader = $command.ExecuteReader()
$a = @()
while ($reader.Read()) {
$a = $a + $reader.GetString(0)
}
$connection.close()
last, let’s create a simple window (a Form) with a list (a List box) where you can select an item with a doubleclick.
Initialize the list with the array from EMP
$form = New-Object Windows.Forms.Form
$form.Text = "Select employee !"
$form.Size = New-Object Drawing.Size(640,480)
$form.StartPosition = "CenterScreen"
$listbox = New-Object Windows.Forms.ListBox
$listbox.Location = New-Object Drawing.Point(10,10)
$listbox.Size = New-Object Drawing.Size(620,460)
$listbox.Items.AddRange($a)
$listbox.Add_DoubleClick({$form.Close();})
$form.Controls.Add($listbox)
$form.Topmost = $True
$form.Add_Shown({$form.Activate()})
[void] $form.ShowDialog()
Show the result (or use it in your powershell scripts)
PS> $listbox.SelectedItems[0]
SCOTT
Pretty cool! No compiler needed, directly run from the powershell prompt
출처 : http://laurentschneider.com/wordpress/2012/05/my-first-net-gui-in-powershell.html
'-- PowerShell' 카테고리의 다른 글
Using PowerShell to call a WCF Service (0) | 2012.09.06 |
---|---|
Encrypt all stored procedures with powershell (0) | 2012.09.03 |
powershell로 이벤트로그와 프로세스 구하기 (0) | 2011.08.17 |
powershell로 ping 테스트 (0) | 2011.08.17 |
PowerShell로 웹소스 가져오기 (0) | 2011.08.17 |
RECENT COMMENT