Aug 06 2023 09:35 AM - edited Aug 06 2023 09:36 AM
PnP code to connect the SQL database and get the data into dataset by using select query
Aug 07 2023 10:16 AM
Aug 07 2023 10:48 PM - edited Aug 15 2023 08:11 AM
I am getting the data into the data-reader after connecting and getting the data from SQL database table. Instead-of this I want to load the data into the data table or dataset so that I can close the SQL connection ($connection.Close()) to improve the performance.
My present code for your reference below :-
$command = New-Object System.Data.SqlClient.SqlCommand($query, $connection)
$reader = $command.ExecuteReader()
while ($reader.Read())
{
for ($i = 0; $i -lt $Reader.FieldCount; $i++)
{
$SourceSiteUrl = $Reader.GetValue(0)
$TargetSiteUrl =$Reader.GetValue(1)
}
}
}
catch
{
Write-Host "Update exception msg " $_.Exception.Message
}
finally
{
$connection.Close()
}