[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

FredericP

5/13/2002 5:03:00 PM

How can i make an SQLTables to get name and info about all tables of a DSN
with ODBC.NET ?


When i play with FillSchema, i must have defined first à OdbcDataAdapter
with à SQLCommand like "select * from mytable"
But "mytable" is the item i want to fetch, so how can i do ?

Thank's by advance.


8 Answers

Xidong Zhang

5/15/2002 5:57:00 PM

0

It seems that SQLTables functionality is NOT exposed in
the Odbc.NET data provider!! I'm so very confused why
Microsoft made that kind of mind!!

>-----Original Message-----
>How can i make an SQLTables to get name and info about
all tables of a DSN
>with ODBC.NET ?
>
>
>When i play with FillSchema, i must have defined first à
OdbcDataAdapter
>with à SQLCommand like "select * from mytable"
>But "mytable" is the item i want to fetch, so how can i
do ?
>
>Thank's by advance.
>
>
>.
>

(Hussein Abuthuraya(MSFT))

5/16/2002 12:46:00 AM

0

Tim Waugh

5/16/2002 2:28:00 PM

0

The OleDbConnection class has a method called GetOleDbSchemaTable which
allows you to dynamically discover what tables are available in a given data
source. The OdbcConnection class does not have a similiar method. This is
the missing functionality!

Thanks,
Tim Waugh

"Hussein Abuthuraya(MSFT)" <HussAbOnline@microsoft.com> wrote in message
news:bwyzmJG$BHA.1956@cpmsftngxa07...
> Xidong,
>
> I'm not getting what you are asking for. What is the functionality you
are looking for that is not in provided by ADO.NET and/or Odbc.NET? Can you
explain?
>
>
> Thanks,
> Hussein Abuthuraya
> Microsoft Developer Support
>
> This posting is provided "AS IS" with no warranties, and confers no
rights.
>
> Are you secure? For information about the Microsoft Strategic Technology
Protection Program and to order your FREE Security Tool Kit, please visit
> http://www.microsoft.co....
>


Xidong Zhang

5/17/2002 4:40:00 PM

0

Hussein,

Please see the original post by FredericP. What I mean is
the same as FredericP's. How can we get table name using
ODBC.NET, just like SQLTables? The functionality like
SQLTables is not provided by ODBC.NET, is it?

Xidong

>-----Original Message-----
>Xidong,
>
>I'm not getting what you are asking for. What is the
functionality you are looking for that is not in provided
by ADO.NET and/or Odbc.NET? Can you explain?
>
>
>Thanks,
>Hussein Abuthuraya
>Microsoft Developer Support
>
>This posting is provided "AS IS" with no warranties, and
confers no rights.
>
>Are you secure? For information about the Microsoft
Strategic Technology Protection Program and to order your
FREE Security Tool Kit, please visit
>http://www.microsoft.co....
>

Xidong Zhang

5/17/2002 4:42:00 PM

0

Hi Tim,

We're talking about ODBC.NET data provider, not OleDb data
provider. I just want to mention that they are different
things.

Xidong

>-----Original Message-----
>The OleDbConnection class has a method called
GetOleDbSchemaTable which
>allows you to dynamically discover what tables are
available in a given data
>source. The OdbcConnection class does not have a similiar
method. This is
>the missing functionality!
>
>Thanks,
>Tim Waugh
>
>"Hussein Abuthuraya(MSFT)" <HussAbOnline@microsoft.com>
wrote in message
>news:bwyzmJG$BHA.1956@cpmsftngxa07...
>> Xidong,
>>
>> I'm not getting what you are asking for. What is the
functionality you
>are looking for that is not in provided by ADO.NET and/or
Odbc.NET? Can you
>explain?
>>
>>
>> Thanks,
>> Hussein Abuthuraya
>> Microsoft Developer Support
>>
>> This posting is provided "AS IS" with no warranties,
and confers no
>rights.
>>
>> Are you secure? For information about the Microsoft
Strategic Technology
>Protection Program and to order your FREE Security Tool
Kit, please visit
>> http://www.microsoft.co....
>>
>
>
>.
>

(Hussein Abuthuraya(MSFT))

5/17/2002 9:54:00 PM

0

Tim Waugh

5/20/2002 2:26:00 PM

0

The missing functionality in OdbcConnection can be 'simulated' by using
InteropServices.

See attached C# console application which contains a class called
OdbcInterOp. This should work against any ODBC driver (no need for a
database specific solution). Beware, I don't throw exceptions on any ODBC
failure (I was a bit lazy), you will need to add this yourself.








"Hussein Abuthuraya(MSFT)" <HussAbOnline@microsoft.com> wrote in message
news:kK1Txyd$BHA.2260@cpmsftngxa08...
>
> The ODBC.NET Data Provider doesn't have an equivalent to
GetOleDbSchemaTable method. Why? I'm not sure.
>
> I know one way to get the list of tables from SQL Server, see the below
code. For different databases, you should get the same information using an
equivalent Select
> statement.
>
> OK to get a list of tables in a specific Database, you need to run a TSQL
> command that gets you this. Here is a sample code:
>
> Dim nwindConn As OdbcConnection = New
> OdbcConnection("dsn=NwindSqlODBC;uid=sa;pwd=")
> Dim salesCMD As OdbcCommand = New OdbcCommand("select * from
> Sysobjects where type='U'", nwindConn)
> salesCMD.CommandType = CommandType.Text
> nwindConn.Open()
> Dim myReader As OdbcDataReader
> myReader = salesCMD.ExecuteReader()
> While myReader.Read
> Console.Write(myReader("name") & vbNewLine)
> End While
> myReader.Close()
> nwindConn.Close()
>
> I hope this helps!
>
>
> Thanks,
> Hussein Abuthuraya
> Microsoft Developer Support
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
> Are you secure? For information about the Microsoft Strategic Technology
> Protection Program and to order your FREE Security Tool Kit, please visit
> http://www.microsoft.co....
>


begin 666 odbcinterop.txt
M=7-I;F<@4WES=&5M.PT*=7-I;F<@4WES=&5M+D-O;&QE8W1I;VYS.PT*=7-I
M;F<@4WES=&5M+E1E>'0[#0IU<VEN9R!3>7-T96TN4G5N=&EM92Y);G1E<F]P
M4V5R=FEC97,[#0H-"FYA;65S<&%C92!->4]D8F,-"GL-"@T*(" @('!U8FQI
M8R!C;&%S<R!/9&)C26YT97)/< T*(" @('L-"B @(" @(" @<'5B;&EC(&-O
M;G-T('-T<FEN9R!D;&QN86UE(#T@(F]D8F,S,BYD;&PB.PT*(" @(" @("!P
M=6)L:6,@8V]N<W0@<W1R:6YG('1A8FQE<R ](")<)U1!0DQ%7"<B.PT*(" @
M(" @("!P=6)L:6,@8V]N<W0@:6YT($1E9F%U;'1-87!P:6YG(" ](#DY.PT*
M(" @(" @("!P=6)L:6,@96YU;2!/9&)C4W1A='5S('L@4W5C8V5S<R ](# L
M(%-U8V-E<W-7:71H26YF;R ](#$@?3L-"@T*(" @(" @("!P<FEV871E($%R
M<F%Y3&ES="!?=&%B;&5S(#T@;F5W($%R<F%Y3&ES="@I.PT*#0H@(" @(" @
M('!U8FQI8R!/9&)C26YT97)/<"AS=')I;F<@9'-N*0T*(" @(" @("![#0H@
M(" @(" @(" @("!0;W!U;&%T92@@9'-N("D[#0H@(" @(" @('T-"@T*(" @
M(" @("!;1&QL26UP;W)T*&1L;&YA;64L($5N=')Y4&]I;G0](E-13$%L;&]C
M16YV(BE=#0H@(" @(" @('!U8FQI8R!S=&%T:6,@97AT97)N($EN=#$V($%L
M;&]C16YV*')E9B!);G0S,B!H96YV*3L-"@T*(" @(" @("!;1&QL26UP;W)T
M*&1L;&YA;64L($5N=')Y4&]I;G0](E-13$%L;&]C0V]N;F5C="(I70T*(" @
M(" @("!P=6)L:6,@<W1A=&EC(&5X=&5R;B!);G0Q-B!!;&QO8T-O;FYE8W0H
M26YT,S(@:&5N=BP@<F5F($EN=#,R(&AC;VYN*3L-"@T*(" @(" @("!;1&QL
M26UP;W)T*&1L;&YA;64L($5N=')Y4&]I;G0](E-13$%L;&]C4W1M="(I70T*
M(" @(" @("!P=6)L:6,@<W1A=&EC(&5X=&5R;B!);G0Q-B!!;&QO8U-T;70H
M26YT,S(@:&-O;FXL(')E9B!);G0S,B!H<W1M="D[#0H-"B @(" @(" @6T1L
M;$EM<&]R="AD;&QN86UE+"!%;G1R>5!O:6YT/2)344Q&<F5E16YV(BE=#0H@
M(" @(" @('!U8FQI8R!S=&%T:6,@97AT97)N($EN=#$V($9R965%;G8H26YT
M,S(@:&5N=BD[#0H-"B @(" @(" @6T1L;$EM<&]R="AD;&QN86UE+"!%;G1R
M>5!O:6YT/2)344Q&<F5E0V]N;F5C="(I70T*(" @(" @("!P=6)L:6,@<W1A
M=&EC(&5X=&5R;B!);G0Q-B!&<F5E0V]N;F5C="A);G0S,B!H8V]N;BD[#0H-
M"B @(" @(" @6T1L;$EM<&]R="AD;&QN86UE+"!%;G1R>5!O:6YT/2)344Q$
M:7-C;VYN96-T(BE=#0H@(" @(" @('!U8FQI8R!S=&%T:6,@97AT97)N($EN
M=#$V($1I<V-O;FYE8W0H26YT,S(@:&-O;FXI.P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T-"@T*
M(" @(" @("!P=6)L:6,@:6YT(%1A8FQE0V]U;G0-"B @(" @(" @>PT*(" @
M(" @(" @(" @9V5T('L@<F5T=7)N(%]T86)L97,N0V]U;G0[('T-"B @(" @
M(" @?0T*#0H@(" @(" @('!U8FQI8R!)16YU;65R871O<B!486)L945N=6UE
M<F%T;W(-"B @(" @(" @>PT*(" @(" @(" @(" @9V5T('L@<F5T=7)N(%]T
M86)L97,N1V5T16YU;65R871O<B@I.R!]#0H@(" @(" @('T-"@T*(" @(" @
M("!P<FEV871E('9O:60@4&]P=6QA=&4H<W1R:6YG(&1S;BD-"@D)>PT*(" @
M(" @(" @(" @26YT,38@<F,[#0H@(" @(" @(" @("!);G0S,B!H96YV(#T@
M,#L-"B @(" @(" @(" @($EN=#,R(&AC;VYN(#T@,#L-"B @(" @(" @(" @
M($EN=#,R(&AS=&UT(#T@,#L-"B @(" @(" @(" @($EN=#,R(&EN9$QE;B ]
M(# [#0H@(" @(" @(" @("!S:&]R="!O=71,96X@/2 P.PT*(" @(" @(" @
M(" @8GET95M=(&)U9F8@/2!N97<@8GET95LR-39=.PT*( T*(" @(" @(" @
M(" @<F,@/2!/9&)C26YT97)/<"Y!;&QO8T5N=B@@<F5F(&AE;G8@*3L-"B @
M(" @(" @(" @(&EF("@@3V1B8TEN=&5R3W N27-/2R@@<F,@*2 I#0H@(" @
M(" @(" @("![#0H@(" @(" @(" @(" @(" @<F,@/2!/9&)C26YT97)/<"Y!
M;&QO8T-O;FYE8W0H(&AE;G8L(')E9B!H8V]N;B I.PT*(" @(" @(" @(" @
M(" @(&EF("@@3V1B8TEN=&5R3W N27-/2R@@<F,@*2 I#0H@(" @(" @(" @
M(" @(" @>PT*(" @(" @(" @(" @(" @(" @("!R8R ]($]D8F-);G1E<D]P
M+D1R:79E<D-O;FYE8W0H(&AC;VYN+" P+"!D<VXL("AS:&]R="ED<VXN3&5N
M9W1H+"!B=69F+" H<VAO<G0I8G5F9BY,96YG=&@L(')E9B!O=71,96XL(# @
M*3L-"B @(" @(" @(" @(" @(" @(" @:68@*"!/9&)C26YT97)/<"Y)<T]+
M*"!R8R I("D-"B @(" @(" @(" @(" @(" @(" @>PT*(" @(" @(" @(" @
M(" @(" @(" @(" @<F,@/2!/9&)C26YT97)/<"Y!;&QO8U-T;70H(&AC;VYN
M+"!R968@:'-T;70@*3L-"B @(" @(" @(" @(" @(" @(" @(" @(&EF("@@
M3V1B8TEN=&5R3W N27-/2R@@<F,@*2 I#0H@(" @(" @(" @(" @(" @(" @
M(" @("![#0H@(" @(" @(" @(" @(" @(" @(" @(" @(" @<F,@/2!/9&)C
M26YT97)/<"Y486)L97,H(&AS=&UT+"!N=6QL+" P+"!N=6QL+" P+" B)2(L
M(#$L('1A8FQE<RP@*'-H;W)T*71A8FQE<RY,96YG=&@@*3L-"B @(" @(" @
M(" @(" @(" @(" @(" @(" @("!I9B H($]D8F-);G1E<D]P+DES3TLH(')C
M("D@*0T*(" @(" @(" @(" @(" @(" @(" @(" @(" @('L-"B @(" @(" @
M(" @(" @(" @(" @(" @(" @(" @(" @3V1B8TEN=&5R3W N0FEN9$-O;"@@
M:'-T;70L(#,L($]D8F-);G1E<D]P+D1E9F%U;'1-87!P:6YG+"!B=69F+"!B
M=69F+DQE;F=T:"P@<F5F(&EN9$QE;B I.PT*#0H@(" @(" @(" @(" @(" @
M(" @(" @(" @(" @(" @('=H:6QE("@@3V1B8TEN=&5R3W N27-/2R@@3V1B
M8TEN=&5R3W N1F5T8V@H(&AS=&UT("D@*2 I#0H@(" @(" @(" @(" @(" @
M(" @(" @(" @(" @(" @('L-"B @(" @(" @(" @(" @(" @(" @(" @(" @
M(" @(" @(" @(%]T86)L97,N061D*"!%;F-O9&EN9RY!4T-)22Y'9713=')I
M;F<H(&)U9F8L(# L(&EN9$QE;B I("D[#0H@(" @(" @(" @(" @(" @(" @
M(" @(" @(" @(" @('T-"B @(" @(" @(" @(" @(" @(" @(" @(" @("!]
M#0H@(" @(" @(" @(" @(" @(" @(" @(" @(" @3V1B8TEN=&5R3W N1G)E
M95-T;70H(&AS=&UT("D[#0H@(" @(" @(" @(" @(" @(" @(" @("!]#0H@
M(" @(" @(" @(" @(" @(" @(" @("!/9&)C26YT97)/<"Y$:7-C;VYN96-T
M*"!H8V]N;B I.PT*(" @(" @(" @(" @(" @(" @("!]#0H@(" @(" @(" @
M(" @(" @(" @($]D8F-);G1E<D]P+D9R965#;VYN96-T*"!H8V]N;B I.PT*
M(" @(" @(" @(" @(" @('T-"B @(" @(" @(" @(" @("!/9&)C26YT97)/
M<"Y&<F5E16YV*"!H96YV("D[#0H@(" @(" @(" @("!]#0H)"7T-"B @("!]
M#0H-"@EC;&%S<R!#;&%S<S$-"@E[#0H)"0T*"0E;4U1!5&AR96%D70T*"0ES
M=&%T:6,@=F]I9"!-86EN*'-T<FEN9UM=(&%R9W,I#0H)"7L-"B @(" @(" @
M(" @($]D8F-);G1E<D]P(&]D8F,@/2!N97<@3V1B8TEN=&5R3W H(")#;VUP
M;&EA;F-E(B I.PT*(" @(" @(" @(" @245N=6UE<F%T;W(@:70@/2!O9&)C
M+E1A8FQE16YU;65R871O<CL-"B @(" @(" @(" @('=H:6QE("@@:70N36]V
M94YE>'0H*2 I#0H@(" @(" @(" @("![#0H@(" @(" @(" @(" @(" @0V]N
M<V]L92Y7<FET94QI;F4H(")[,'TB+"!I="Y#=7)R96YT("D[#0H@(" @(" @
M(" @("!]#0H@(" @(" @(" @(" -"B @(" @(" @(" @($-O;G-O;&4N5W)I
M=&5,:6YE*" B5&%B;&5S('LP?2(L(&]D8F,N5&%B;&5#;W5N=" I.PT*(" @
/(" @("!]#0H)?0T*?0T*
`
end

Xidong Zhang

5/21/2002 3:50:00 PM

0

Ok, Hussein,

Can you give me another example except SQL Server (I think
that I will never connect to SQL Server using ODBC.NET
provider instead of SqlClient), say, Excel file? How can I
get the worksheet name of a XLS file? I do not know what
is "the same information using an equivalent Select
statement" (between SQL Server and XLS file). (I'm sure
that I can do this task using SQLTables of ODBC API or
GetOleDbSchemaTable of OleDb provider)


>-----Original Message-----
>
>The ODBC.NET Data Provider doesn't have an equivalent to
GetOleDbSchemaTable method. Why? I'm not sure.
>
>I know one way to get the list of tables from SQL Server,
see the below code. For different databases, you should
get the same information using an equivalent Select
>statement.
>
>OK to get a list of tables in a specific Database, you
need to run a TSQL
>command that gets you this. Here is a sample code:
>
> Dim nwindConn As OdbcConnection = New
>OdbcConnection("dsn=NwindSqlODBC;uid=sa;pwd=")
> Dim salesCMD As OdbcCommand = New OdbcCommand
("select * from
>Sysobjects where type='U'", nwindConn)
> salesCMD.CommandType = CommandType.Text
> nwindConn.Open()
> Dim myReader As OdbcDataReader
> myReader = salesCMD.ExecuteReader()
> While myReader.Read
> Console.Write(myReader("name") & vbNewLine)
> End While
> myReader.Close()
> nwindConn.Close()
>
> I hope this helps!
>
>
> Thanks,
> Hussein Abuthuraya
> Microsoft Developer Support
>
> This posting is provided "AS IS" with no warranties, and
confers no
>rights.
>
> Are you secure? For information about the Microsoft
Strategic Technology
>Protection Program and to order your FREE Security Tool
Kit, please visit
> http://www.microsoft.co....
>