Jan 9, 2018 12:36:00 PM by Deepak Vohra
This is a companion discussion topic for the original entry at https://blog.toadworld.com/2018/01/09/blog-post-getting-started-with-toad-devops-toolkit-running-the-powershell-demos
Jan 9, 2018 12:36:00 PM by Deepak Vohra
Hi,
I would really appreciate your help in regards to below issue that I am facing.
So, I have 2 different servers. One server has TDT installed and other has oracle database installed. I am trying to to make connection using TDT to this database server. I am using below format.
$Source = $TDT.Connections.NewConnection("userid/pass123@hostname:PORT/databaseschemaName")
I get below Exception:
Access violation at address 0000000006BED2C0 in module 'tdt.exe'. Read of address 00000000000000C4
At C:\Users\cloud-user\Documents\test.ps1:15 char:6
+ $Source = $TDT.Connections.NewConnection("user/pass123@hostname ...
*+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
Am I missing something in connection String as error points to the line where I am trying to connect to database server. I am really stuck with this issue. I would really appreciate your help to resolve this issue. Thank You!
Hi Amit,
In order to have the demos work, you'll need an Oracle client installed on the server on which you want to run TDT. This client should match the same "bit-ness" as TDT (32-bit Oracle client for 32-bit TDT, and 64-bit Oracle client for 64-bit TDT).
Once you have that installed, you'll need to create an instance of the TDT object within your script before you start using it. You can accomplish that with the following command:
$TDT = New-Object -ComObject Toad.ToadAutoObject
This will create an instance of the COM object so that you can use it. From there, you can use the connection string you need, as in your statement above. It's usually a good idea to enclose your script within a try...finally block so that you can make sure that TDT's process is released when you're done.
An example of this within a script, using your connection string, might be:
$TDT = New-Object -ComObject Toad.ToadAutoObject
try {
$Source = $TDT.Connections.NewConnection("userid/pass@databasename")
# Do something with the connection
$Script = $TDT.Scripts.Add()
$Script.Connection = $Source
$Script.IncludeOutput = $TRUE
$Script.MaxRows = 100
$Script.InputFile = "C:\Temp\myquery.sql"
# Execute the script
$Script.Execute()
# Output Results
$ScriptOutput = $Script.OutputText
}
finally {
$TDT.Quit()
}
You can find further examples within the TDT installation folder under "Examples\COM\PowerShell". You can also find various tutorial videos and articles on our blog site here:
If you have additional questions, feel free to post them to the Toad Devops Toolkit forum, which can be located here:
https://forums.toadworld.com/c/toad-devops-toolkit
Thanks for your question!
-John
Hi John,
Thanks for taking your time and looking into my issue. Yes, I did miss on installing Oracle client. Now, I am able to connect to database and execute queries after installing Oracle client, So Thank You! I will definitely reach out on TDT forum for any further questions. Have a good day!
Many Thanks,
Amit