Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Powershell 32 vs. 64 when using ADODB

Reply
 
Old 12-29-2006   #1 (permalink)
Jakob Bindslet


 
 

Powershell 32 vs. 64 when using ADODB

Hi Group,

I've been trying to create a simple script to extract data from an SQL2005
database using PowerShell.

However, when trying to use ADODB in powershell (from a Win2K3R2SP1 server)
I get the following problem:

Script:
$objConnection = New-Object -comobject ADODB.Connection
$objConnection.Set_ConnectionString("Provider=SQLOLEDB; Data
Source=servername\instancename; Initial Catalog=master; Integrated
Security=SSPI")

On PowerShell 32bit, there are no problems, but the 64bit version gives the
following result:

Method invocation failed because
[System.__ComObject#{00000550-0000-0010-8000-00aa006d2ea4}] doesn't contain a
method named 'Set_ConnectionString'.
At line:1 char:36
+ $objConnection.Set_ConnectionString( <<<< "Provider=SQLOLEDB; Data
Source=servername\instancename; Initial Catalog=master; Integrated
Security=SSPI")

How do I solve this issue ??



My System SpecsSystem Spec
Old 12-29-2006   #2 (permalink)
RichS


 
 

RE: Powershell 32 vs. 64 when using ADODB

As PowerShell is .net based why not use the .net providers eg

#init the command and connection
$connString = "server=.;Integrated Security=SSPI;database=adventureworks"
$cn = new-object "System.Data.SqlClient.SqlConnection" $connString

# create the command
$cmd = new-object "System.Data.SqlClient.SqlCommand"
$cmd.CommandType = [System.Data.CommandType]"Text"
$cmd.CommandText = "SELECT * FROM Production.Product"

#get the data
$dt = new-object "System.Data.DataTable"
$cmd.Connection = $cn
$cn.Open()
$rdr = $cmd.ExecuteReader()
$dt.Load($rdr)
$cn.Close()
$dt | Format-Table


--
Richard Siddaway

Please note that all scripts are supplied "as is" and with no warranty


"Jakob Bindslet" wrote:

> Hi Group,
>
> I've been trying to create a simple script to extract data from an SQL2005
> database using PowerShell.
>
> However, when trying to use ADODB in powershell (from a Win2K3R2SP1 server)
> I get the following problem:
>
> Script:
> $objConnection = New-Object -comobject ADODB.Connection
> $objConnection.Set_ConnectionString("Provider=SQLOLEDB; Data
> Source=servername\instancename; Initial Catalog=master; Integrated
> Security=SSPI")
>
> On PowerShell 32bit, there are no problems, but the 64bit version gives the
> following result:
>
> Method invocation failed because
> [System.__ComObject#{00000550-0000-0010-8000-00aa006d2ea4}] doesn't contain a
> method named 'Set_ConnectionString'.
> At line:1 char:36
> + $objConnection.Set_ConnectionString( <<<< "Provider=SQLOLEDB; Data
> Source=servername\instancename; Initial Catalog=master; Integrated
> Security=SSPI")
>
> How do I solve this issue ??
>
>

My System SpecsSystem Spec
Old 12-29-2006   #3 (permalink)
Jakob Bindslet


 
 

Re: Powershell 32 vs. 64 when using ADODB

On Fri, 29 Dec 2006 06:58:01 -0800, RichS
<RichS@discussions.microsoft.com> wrote:

>As PowerShell is .net based why not use the .net providers eg
>
>#init the command and connection
>$connString = "server=.;Integrated Security=SSPI;database=adventureworks"
>$cn = new-object "System.Data.SqlClient.SqlConnection" $connString
>
># create the command
>$cmd = new-object "System.Data.SqlClient.SqlCommand"
>$cmd.CommandType = [System.Data.CommandType]"Text"
>$cmd.CommandText = "SELECT * FROM Production.Product"
>
>#get the data
>$dt = new-object "System.Data.DataTable"
>$cmd.Connection = $cn
>$cn.Open()
>$rdr = $cmd.ExecuteReader()
>$dt.Load($rdr)
>$cn.Close()
>$dt | Format-Table


Yes, that would be a solution. But I would still like to know what
differences there are between PowerShell 32 and 64.

Has anybody compared speed or functionality between the two versions ?


--
Jakob Bindslet


My System SpecsSystem Spec
Old 12-29-2006   #4 (permalink)
Steve Foster [SBS MVP]


 
 

Re: Powershell 32 vs. 64 when using ADODB

Jakob Bindslet wrote:

>On Fri, 29 Dec 2006 06:58:01 -0800, RichS
><RichS@discussions.microsoft.com> wrote:
>
>>As PowerShell is .net based why not use the .net providers eg
>>
>>#init the command and connection
>>$connString = "server=.;Integrated Security=SSPI;database=adventureworks"
>>$cn = new-object "System.Data.SqlClient.SqlConnection" $connString
>>
>># create the command
>>$cmd = new-object "System.Data.SqlClient.SqlCommand"
>>$cmd.CommandType = [System.Data.CommandType]"Text"
>>$cmd.CommandText = "SELECT * FROM Production.Product"
>>
>>#get the data
>>$dt = new-object "System.Data.DataTable"
>>$cmd.Connection = $cn
>>$cn.Open()
>>$rdr = $cmd.ExecuteReader()
>>$dt.Load($rdr)
>>$cn.Close()
>>$dt | Format-Table

>
>Yes, that would be a solution. But I would still like to know what
>differences there are between PowerShell 32 and 64.


The difference (in this case at least) is not PowerShell. The difference
is that ADO only comes in 32-bit. I'm surprised that you can even
instantiate an ADO COM object in 64-bit!

--
Steve Foster [SBS MVP]
---------------------------------------
MVPs do not work for Microsoft. Please reply only to the newsgroups.
My System SpecsSystem Spec
Old 01-05-2007   #5 (permalink)
Chuck Heatherly


 
 

Re: Powershell 32 vs. 64 when using ADODB

On Fri, 29 Dec 2006 15:20:43 -0800, "Steve Foster [SBS MVP]"
<steve.foster@picamar.co.uk> wrote:

>>On Fri, 29 Dec 2006 06:58:01 -0800, RichS
>><RichS@discussions.microsoft.com> wrote:
>>

[snip]
>>
>>Yes, that would be a solution. But I would still like to know what
>>differences there are between PowerShell 32 and 64.

>
>The difference (in this case at least) is not PowerShell. The difference
>is that ADO only comes in 32-bit. I'm surprised that you can even
>instantiate an ADO COM object in 64-bit!


Where are you getting this information?

According to:
http://msdn2.microsoft.com/en-us/library/ms676506.aspx

"ADO 2.7 introduces support for 64-bit processors."

I've used ADO from C# on an x64 machine to connect to my company's
64-bit OLE DB provider, so I know it works.

Chuck
My System SpecsSystem Spec
Old 01-05-2007   #6 (permalink)
Steve Foster [SBS MVP]


 
 

Re: Powershell 32 vs. 64 when using ADODB

Chuck Heatherly wrote:

>On Fri, 29 Dec 2006 15:20:43 -0800, "Steve Foster [SBS MVP]"
><steve.foster@picamar.co.uk> wrote:
>
>>>On Fri, 29 Dec 2006 06:58:01 -0800, RichS
>>><RichS@discussions.microsoft.com> wrote:
>>>

>[snip]
>>>
>>>Yes, that would be a solution. But I would still like to know what
>>>differences there are between PowerShell 32 and 64.

>>
>>The difference (in this case at least) is not PowerShell. The difference
>>is that ADO only comes in 32-bit. I'm surprised that you can even
>>instantiate an ADO COM object in 64-bit!

>
>Where are you getting this information?


Ah, um, I might have been getting ADO mixed up with DAO.


>According to:
>http://msdn2.microsoft.com/en-us/library/ms676506.aspx
>
>"ADO 2.7 introduces support for 64-bit processors."
>
>I've used ADO from C# on an x64 machine to connect to my company's
>64-bit OLE DB provider, so I know it works.


ADO or ADO.NET?

--
Steve Foster [SBS MVP]
---------------------------------------
MVPs do not work for Microsoft. Please reply only to the newsgroups.
My System SpecsSystem Spec
Old 01-09-2007   #7 (permalink)
Chuck Heatherly


 
 

Re: Powershell 32 vs. 64 when using ADODB

On Fri, 05 Jan 2007 16:59:16 -0800, "Steve Foster [SBS MVP]"
<steve.foster@picamar.co.uk> wrote:

>Chuck Heatherly wrote:
>
>>I've used ADO from C# on an x64 machine to connect to my company's
>>64-bit OLE DB provider, so I know it works.

>
>ADO or ADO.NET?


ADO, also referred to by its library name ADODB, as in the title of
this thread. The OLE DB provider I'm using in my case doesn't support
SQL, so ADO.NET is useless.

Chuck
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
64-bit PowerShell won't load ADODB type library PowerShell
Using SUM with ADODB object VB Script
Using ADODB VB Script
Difficulties using ADODB.recordset in powershell PowerShell
ADODB: com and .net PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46