HighTechTalks DotNet Forums  

Generic Connection String

Dotnet Framework (ODBC.net) microsoft.public.dotnet.framework.odbcnet


Discuss Generic Connection String in the Dotnet Framework (ODBC.net) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Tim Marsden
 
Posts: n/a

Default Generic Connection String - 12-08-2003 , 07:35 AM






Hi,

I need to present the user with a list of Tables from a database.
After they have selected the table I need to present them with a list of
Fields.
After they select the Fields they require, I need to use an ODBCDataReader
to retrieve the Data. It NEEDS to be an ODBCDataReader.

I cannot find a way of retrieving the list of Tables using the ODBC.NET data
provider. (Is there a way ?)
I can get a list of Fields using the ODBCDataReader.

Because I cannot get a list of Tables I have to use a different method eg
ADOX.
However the connection strings are different. Is there a way of defining a
generic connection string so I can use it in ADOX to get the list of Tables
and in the ODBCConnection to get the data?

I want an easy way for the user to select the database they are using, it
can be any ODBC compliant database, Currently I am using the Data Link
Properties dialog (I believe this is for OLEDB) , but this is messy for
ODBC. Is there an equivalent for ODBC?, or SQLClient?

Thanks
Tim



Reply With Quote
  #2  
Old   
Mythran
 
Posts: n/a

Default Re: Generic Connection String - 12-08-2003 , 04:24 PM







"Tim Marsden" <TM (AT) UK (DOT) COM> wrote

Quote:
Hi,

I need to present the user with a list of Tables from a database.
After they have selected the table I need to present them with a list of
Fields.
After they select the Fields they require, I need to use an ODBCDataReader
to retrieve the Data. It NEEDS to be an ODBCDataReader.

I cannot find a way of retrieving the list of Tables using the ODBC.NET data
provider. (Is there a way ?)
I can get a list of Fields using the ODBCDataReader.

Because I cannot get a list of Tables I have to use a different method eg
ADOX.
However the connection strings are different. Is there a way of defining a
generic connection string so I can use it in ADOX to get the list of Tables
and in the ODBCConnection to get the data?

I want an easy way for the user to select the database they are using, it
can be any ODBC compliant database, Currently I am using the Data Link
Properties dialog (I believe this is for OLEDB) , but this is messy for
ODBC. Is there an equivalent for ODBC?, or SQLClient?

Thanks
Tim


I had the same problem, but for me, I switched from Sql to ODBC because of some
issues that ODBC resolves but Sql doesn't. Anywho, you will have to re-connect
to the database after retrieving the list of tables using the ADO. I believe
this is how i did it

Once you have all the properties required by the ODBC.Net driver, reconnect using
the ODBC connection string.

Mythran





Reply With Quote
  #3  
Old   
AT
 
Posts: n/a

Default RE: Generic Connection String - 12-09-2003 , 01:54 AM



Hi Tim,

If you're using OleDbConnection class, you can use
OleDbConnection.GetOleDbSchemaTable method to get the table information
from the connection. However, this is not provided in ODBCConnection class.
I think you can use ADOX to retrived them from the database.

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


Reply With Quote
  #4  
Old   
Tim Marsden
 
Posts: n/a

Default Re: Generic Connection String - 12-09-2003 , 03:59 AM



Hi
I realise I cannot use the ODBC provider to obtains schema info for the
table, and have to use ADOX.
But I only want to define the connection information once, and use this to
connect to ADOX to get the schema, and then to ODBC to get the data. ( the
user defines which database to use, I don't want them to have to define 2
lots of connection info.)

What are the common elements I need to define for the ADOX connection and
the ODBC.net connection. Is there a "Connection" dialog I can use?

Tim

"Kevin Yu [MSFT]" <v-kevy (AT) online (DOT) microsoft.com> wrote

Quote:
Hi Tim,

If you're using OleDbConnection class, you can use
OleDbConnection.GetOleDbSchemaTable method to get the table information
from the connection. However, this is not provided in ODBCConnection
class.
I think you can use ADOX to retrived them from the database.

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."




Reply With Quote
  #5  
Old   
AT
 
Posts: n/a

Default Re: Generic Connection String - 12-10-2003 , 01:32 AM



Hi Tim,

ADOX uses an ADOX.Catalog as a connection. I think you can share the
connection string of the ODBC.net connection with it. If you need a dialog
box to choose a connection to the database, here's a KB article of how to
invoke the OLE DB Data Link Properties dialog box in Visual Basic code

http://support.microsoft.com/default...b;en-us;286189

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.