Resources for IT Professionals > Forums Home > Windows Server Forums > Windows PowerShell > Test an ODBC driver connection with Powershell ?

Answered Test an ODBC driver connection with Powershell ?

  • Thursday, September 02, 2010 1:08 PM
     
     

    Hello All !

    I have a Windows 2003 platform with Powershell v1 installed.

    I installed an odbc driver with a package in powershell. But I want to test the connection of this odbc driver using Powershell, without installing SQL Server. The "Invoke-Sql" command comes with SQL 2008 (R2).

    Is there another way to test a connection with an ODBC driver with powershell script ?

     


    Thanks for advance for your ideas / help - Regards - Have a nice day ! RHUM2

Answers

  • Thursday, September 02, 2010 7:34 PM
     
     Answered
    its basically the same deal...
     
    $conn = new-object system.data.odbc.odbcconnection
    $conn.connectionstring = "(DSN=dnsname)"
    $conn.open()
     
    Justin
  • Friday, September 03, 2010 7:17 AM
    Moderator
     
     Answered


    As Justin explained, it’s the same deal. We just need to change connectionstring based on different database.

    For your reference:

    Multi-platform database access with PowerShell
    http://theessentialexchange.com/blogs/michael/archive/2008/01/07/multi-platform-database-access-with-powershell.aspx
    Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.

    Thanks.


    This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

All Replies

  • Thursday, September 02, 2010 2:17 PM
     
     

    If you need to connect to a SQL Server data source in PowerShell V1 you can use this function:

    http://poshcode.org/1791

    For a non-SQL Server data source:

    http://poshcode.org/1591

  • Thursday, September 02, 2010 2:39 PM
     
     

    Hello cmille19 !

    Thanks for this link, but it concerns OLEDB not ODBC. I'm looking for ODBC test.

     


    Thanks for advance for your ideas / help - Regards - Have a nice day ! RHUM2
  • Thursday, September 02, 2010 7:34 PM
     
     Answered
    its basically the same deal...
     
    $conn = new-object system.data.odbc.odbcconnection
    $conn.connectionstring = "(DSN=dnsname)"
    $conn.open()
     
    Justin
  • Friday, September 03, 2010 7:17 AM
    Moderator
     
     Answered


    As Justin explained, it’s the same deal. We just need to change connectionstring based on different database.

    For your reference:

    Multi-platform database access with PowerShell
    http://theessentialexchange.com/blogs/michael/archive/2008/01/07/multi-platform-database-access-with-powershell.aspx
    Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.

    Thanks.


    This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
  • Thursday, September 09, 2010 6:47 AM
    Moderator
     
     

    Hi,

    Do you need any other assistance? If there is anything we can do for you, please let us know.

    Thanks.


    This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.