mithrandyr / SimplySql

PowerShell module for querying various SQL databases
MIT License
197 stars 31 forks source link

Connection is not opened when using the -ConnectionName parameter of Open-OracleConnection #125

Closed mdoyle-cvi closed 8 months ago

mdoyle-cvi commented 8 months ago

as per the title, if I specify a string in the -ConnectionName parameter when using Open-OracleConnection, no connection is created

example:

Open-OracleConnection -DataSource "server" -Port 9011 -ServiceName "database" -Credential $Credential -ErrorAction Stop -ConnectionName "test" Get-SqlConnection
WARNING: There is no active SQL Connection. Test-SqlConnection -ConnectionName "test" False

If I don't specify anything then it works fine

example:

Open-OracleConnection -DataSource "server" -Port 9011 -ServiceName "database" -Credential $Credential -ErrorAction Stop Get-SqlConnection
_ConnectionString : DATA SOURCE="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=server)(PORT=9011))(CONNECT_DATA=(SERVICENAME=database)))";STATEMENT
CACHE SIZE=5 State : Open
Test-SqlConnection -ConnectionName "default" True

mithrandyr commented 8 months ago

@mdoyle-cvi -- I can't reproduce your issue. I'm using the latest released version (1.9) in Windows PowerShell 5.1

Open-OracleConnection -DataSource localhost -ServiceName xe -Credential (Get-Credential) -ConnectionName test
Get-SqlConnection test
Show-SqlConnection test

those work.. meanwhile, if i don't specify a -ConnectionName -- then the default value of "default" will be used and there are no connections of that sort.

Show-SqlConnection -All

please provide the output of $PSVersionTable

mdoyle-cvi commented 8 months ago

Also using PowerShell 5.1, and v 1.9.1 of this module. Interestingly, Show-SqlConnection -All does show the "test" connection, but Get-SqlConnection does not. and Close-SqlConnection cannot close it either, and Invoke-SqlQuery can't query it either, very odd.

Name Value


PSVersion 5.1.22621.2506 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.22621.2506 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1

mdoyle-cvi commented 8 months ago

This is working now, not sure why exactly. I uninstalled the SQLServer module since yours supports more than just MSSQLServer and now it is working, so perhaps they were conflicting somehow.

mithrandyr commented 8 months ago

Glad that you were able to resolve.