logo
down
shadow

Sql Command (Exception calling "ExecuteScalar" with "0" argument)


Sql Command (Exception calling "ExecuteScalar" with "0" argument)

By : user3851609
Date : October 16 2020, 11:12 AM
it fixes the issue That is a common error that occurs if you try to execute a command using a connection that was reset by the server. It happens to me all the time whenever I run a Powershell script, restart the SQL Server, and then try and run the script again. The script thinks that the connection is still open, but when it tries to use it you get a transport-level error and it closes the connection. When you try to run the script again it will re-establish the connection and everything works fine.
If you want to force it to close the connection simply execute the $SqlConnection.Close() statement whenever you restart the SQL server.
code :


Share : facebook icon twitter icon
"Exception calling "Substring" with "2" argument(s): "startIndex cannot be larger than len

"Exception calling "Substring" with "2" argument(s): "startIndex cannot be larger than len


By : user2331590
Date : March 29 2020, 07:55 AM
it helps some times I am new to PS. I have what should be a very simple script that needs to detect a substring in lines of a file... , change this:
code :
write-host $data.substring(39,3)
write-host $line.substring(39,3)
Exception calling ".ctor" with "2" argument(s): "SetParent failed for Login 'XXX'."

Exception calling ".ctor" with "2" argument(s): "SetParent failed for Login 'XXX'."


By : Francisco Javier Gon
Date : March 29 2020, 07:55 AM
Does that help According to this you need to set the domain of your $server
Powershell "X509Certificate2Collection" Exception calling "Import" with "3" argument(s): &

Powershell "X509Certificate2Collection" Exception calling "Import" with "3" argument(s): &


By : Rabia Rehman
Date : March 29 2020, 07:55 AM
will help you I have the below piece of code to download cert from Azure Key Vault. , Change the code like this and you are good to go!
code :
    $secretName = "TestCert"
    $kvSecret = Get-AzureKeyVaultSecret -VaultName $vaultName -Name $certificateName
    $kvSecretBytes = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($kvSecret.SecretValueText))
    $jsonCert = ConvertFrom-Json($kvSecretBytes)
    $certBytes = [System.Convert]::FromBase64String($jsonCert.data)
    $certCollection = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2Collection
    $certCollection.Import($certBytes,$jsonCert.password,[System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::Exportable)
Exception calling "InvokeSet" with "2" argument(s): "Unknown error (0x80005000)"

Exception calling "InvokeSet" with "2" argument(s): "Unknown error (0x80005000)"


By : user1780598
Date : March 29 2020, 07:55 AM
may help you . The answer to this problem is that I'm an idiot.
This code is correct
code :
$User = [ADSI] "LDAP://$using:FullUserPath"
$User.psbase.Invokeset("TerminalServicesProfilePath","$using:ProfileLocation")
$user.psbase.InvokeSet("TerminalServicesHomeDrive", "$using:HomeDrive")
$User.psbase.invokeset("TerminalServicesHomeDirectory","$using:HomeLocation")
$User.setinfo()
$FullUserPath        = "CN=$DisplayName,$UserPath"
$DisplayName         = ($FirstName+" "+$LastName).ToString()
Exception calling "ExecuteReader" with "0" argument(s): "Incorrect syntax near '='."

Exception calling "ExecuteReader" with "0" argument(s): "Incorrect syntax near '='."


By : SujathaSam
Date : March 29 2020, 07:55 AM
I wish this help you You forgot to declare $repnr for query's where condition and because of that you get syntax error where aflevdato is null and repnr = .
code :
$repnr = 123
$UserSqlQuery = "SELECT [UdstyrsId]
      ,[Model]
      ,[Serienr]
      ,[Udlevdato]
      ,[Repnr]
      ,[Notat]
  FROM [IT-Support].[dbo].[Udstyrsoplysninger] where aflevdato is null and repnr = $repnr"
shadow
Privacy Policy - Terms - Contact Us © bighow.org