Groups | Blog | Home
all groups > c# > february 2004 >

c# : ODBC API


Arrun S
2/3/2004 11:36:05 PM
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
Miha Markic [MVP C#]
2/4/2004 11:25:16 AM
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

[quoted text, click to view]
a function 'SQLDescribeParam()'. But, I don't know how to access this
function through C#.Could anyone help me?
[quoted text, click to view]

Austin Ehlers
2/4/2004 2:53:38 PM
Have you installed the ODBC .NET Data Provider?

http://www.microsoft.com/downloads/details.aspx?FamilyId=6CCD8427-1017-4F33-A062-D165078E32B1&displaylang=en

Austin

On Tue, 3 Feb 2004 23:36:05 -0800, "Arrun S" <projdqe@yahoo.co.in>
[quoted text, click to view]
William (Bill) Vaughn
2/4/2004 8:29:28 PM
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.
__________________________________

[quoted text, click to view]
a function 'SQLDescribeParam()'. But, I don't know how to access this
function through C#.Could anyone help me?
[quoted text, click to view]

Roy Fine
2/4/2004 11:53:00 PM
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


[quoted text, click to view]
a function 'SQLDescribeParam()'. But, I don't know how to access this
function through C#.Could anyone help me?
[quoted text, click to view]

Tony
4/1/2004 4:57:53 PM
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

[quoted text, click to view]

AddThis Social Bookmark Button