I'm trying to make my SQL commands running asynchronously with PowerShell. To achive this i'm using SqlCommand
class and BeginExecuteNonQuery
method. As far as i know, this method should return IAsyncResult
class. But when I'm trying to inspect returning value i see System.Data.Common.DbAsyncResult
class.
Please tell me what i'm doing wrong or where i can read about my mistake, i'm quite new to programming. My code sample is below
$connection = New-Object System.Data.SqlClient.SqlConnection
"addr=tcp:192.168.0.81,1433;Database=ArchiCredit;uid=sa;password=1;Async=true;"
$connection.Open()
$connection.State
$command = New-Object System.Data.SqlClient.SqlCommand ("update clients set fullname = 'ololo' where id = 15", $connection)
$state = $command.BeginExecuteNonQuery()
$state | gm
result of this script is
PS C:\Users\ivanov> F:\AsyncSQL.ps1
Open
TypeName: System.Data.Common.DbAsyncResult
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()