ODBC API

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I don't know how to access the ODBC API through C#. The VS.NET provides OLEDB Data Provider but not ODBC
E.g., select * from tbl where id=
To get the data type (description) of the column 'id', the ODBC provides a function 'SQLDescribeParam()'. But, I don't know how to access this function through C#.Could anyone help me
TIA
Arrun
 
Hi Arrun,

Have yo checked System.Data.Odbc namespace?
It comes with .net 1.1.

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Arrun S said:
Hi
I don't know how to access the ODBC API through C#. The VS.NET provides
OLEDB Data Provider but not ODBC.
E.g., select * from tbl where id=?
To get the data type (description) of the column 'id', the ODBC provides
a function 'SQLDescribeParam()'. But, I don't know how to access this
function through C#.Could anyone help me?
 
Hi Miha
Thanks for the answer. Is it not possible with .NET 1.0 (which I am using)

----- Miha Markic [MVP C#] wrote: ----

Hi Arrun

Have yo checked System.Data.Odbc namespace
It comes with .net 1.1

--
Miha Markic [MVP C#] - RightHand .NET consulting & software developmen
miha at rthand co
www.rthand.co

Arrun S said:
H
I don't know how to access the ODBC API through C#. The VS.NET provide
OLEDB Data Provider but not ODBC
E.g., select * from tbl where id=
To get the data type (description) of the column 'id', the ODBC provide
a function 'SQLDescribeParam()'. But, I don't know how to access thi
function through C#.Could anyone help me
 
ODBC is built into the 1.1 version of the Framework. It can be downloaded
and used with version 1.0.
However, this is NOT the ODBC API. As I wrote in my books quite some time
ago, the ODBC API requires "Declare" statements the tie the API entry points
to VB functions and subroutines. There is no publicly available set of
headers for use in .NET languages--not that I've heard of.

What are you trying to do? While you can get at the ODBC drivers, the API
interfaces are tough to get to.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Arrun S said:
Hi
I don't know how to access the ODBC API through C#. The VS.NET provides
OLEDB Data Provider but not ODBC.
E.g., select * from tbl where id=?
To get the data type (description) of the column 'id', the ODBC provides
a function 'SQLDescribeParam()'. But, I don't know how to access this
function through C#.Could anyone help me?
 
Arrun,

SQLDescribeParam is a system API call - you would have to use P/Invoke to
get to that one. That's the short answer.

The long answer is that accessing data using the ODBC API is sufficiently
difficult in C#, and the benefits are so few, you are better off looking for
another solution.

For ADO.Net, if you need schema info on a column returned from a server, use
the GetSchemaTable method on the DataReader object.

The GetSchemaTable method works similar to the ODBC API call, in that the
API call works on the prepared statement - there is a round trip to the
server, but the statement does not have to be executed. Using the data
reader approach requires the behavior parameter to be set to SchemaOnly (or
KeyInfo if you want to execute the select query, and get data and schema
info in one trip)

best regards
roy fine


Arrun S said:
Hi
I don't know how to access the ODBC API through C#. The VS.NET provides
OLEDB Data Provider but not ODBC.
E.g., select * from tbl where id=?
To get the data type (description) of the column 'id', the ODBC provides
a function 'SQLDescribeParam()'. But, I don't know how to access this
function through C#.Could anyone help me?
 
This only works if you know what table you want to go after.

What if you need a list of tables, indexes, etc.

Also I need to know what server I'm talking to (Oracle or SQL Server)
because the SQL Syntax is different.

Tony
 
Back
Top