ADO - adSchemaColumns doesn"t seem to work.
am 16.05.2010 21:45:46 von Phil Brierley--001636498b65c5e2920486bb5ad5
Content-Type: text/plain; charset=ISO-8859-1
Hi,
I have some standard code below that seems to work fine with all databases I
have tested including teradata, oracle, sql server etc.
All I am trying to do is return a record set object to the data in a table.
I've just installed and tested it on postgres and it gives me an error -
'object or provider is not capable of performing requested operation'
can anyone give me any clues as to what I am missing?
The code below can be tested in excel if you add a reference to ADO.
Public Sub test()
'connect
Dim cnSim As New ADODB.Connection
Dim connectionstring As String
connectionstring = "Provider=PostgreSQL.1;Password=password;User
ID=postgres;Data Source=localhost;Location=postgres;Extended
Properties="""""
cnSim.connectionstring = connectionstring
cnSim.Open
'list the tables
Dim s As String
Dim s1 As String
Dim rs As New ADODB.Recordset
Set rs = cnSim.OpenSchema(adSchemaTables)
While Not rs.EOF
s = rs!Table_Schema & "." & rs!TABLE_NAME
s1 = rs!TABLE_NAME
Debug.Print s
rs.MoveNext
Wend
'works fine to here.
'try to return record set of a table
Dim aRestrictions As Variant
aRestrictions = Array(Empty, Empty, s, Empty)
'aRestrictions = Array(Empty, Empty, s1, Empty)
Set rs = cnSim.OpenSchema(adSchemaColumns, aRestrictions)
'Error - object or provider is not capable of performing requested
operation'
End Sub
--001636498b65c5e2920486bb5ad5
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
=A0
I have some standard code below that seems to work fine =
with all databases I have tested including teradata, oracle, sql server etc=
..
table.
=A0
I've just installed and tested it on postgres and it =
gives me an error -
=A0
'object or provider is not capable of per=
forming requested operation'
=A0
can anyone give me any clues as to what I am missing?
=A0
The =
code below can be tested in excel if you add a reference to ADO.
=A0
=
Public Sub test()
=A0 'connect
=A0 Dim cnSim As New A=
DODB.Connection
=A0 Dim connectionstring As String
=A0 connectionstring =3D =
"Provider=3DPostgreSQL.1;Password=3Dpassword;User ID=3Dpostgres;Data S=
ource=3Dlocalhost;Location=3Dpostgres;Extended Properties=3D""&qu=
ot;""
=A0 cnSim.connectionstring =3D connectionstring
>
=A0 cnSim.Open
=A0
=A0
=A0 'list the=
tables
=A0 Dim s As String
=A0 Dim s1 As String
=A0=
Dim rs As New ADODB.Recordset
=A0
=A0 Set rs =3D =
cnSim.OpenSchema(adSchemaTables)
While Not rs.EOF
=A0 s =3D rs!Table_Schema & "." & rs!TABLE_NA=
ME
=A0 s1 =3D rs!TABLE_NAME
=A0 Debug.Print s=
=A0 rs.MoveNext
Wend
=A0
'=
;works fine to here.
=A0
=A0 'try to return record s=
et of a table
=A0 Dim aRestrictions As Variant
=A0 aRestrictions =3D Array=
(Empty, Empty, s, Empty)
=A0 'aRestrictions =3D Array(Empty, E=
mpty, s1, Empty)
=A0 Set rs =3D cnSim.OpenSchema(adSchemaColumns, =
aRestrictions)
=A0 'Error - object or provider is not capable =
of performing requested operation'
=A0
End Sub
--001636498b65c5e2920486bb5ad5--