"John Brown" <(E-Mail Removed)> wrote in message
news:197C6525-4154-4C0C-9932-(E-Mail Removed)...
>
>
> "Mark Rae [MVP]" wrote:
>
>> "John Brown" <(E-Mail Removed)> wrote in message
>> news:E7322825-2163-4B59-9AA4-(E-Mail Removed)...
>>
>> >> "John Brown" <(E-Mail Removed)> wrote in message
>> >> news:5F054111-768C-4FD8-86FF-(E-Mail Removed)...
>> >>
>> >> > 2) More generally, is there an equivalent to the
>> >> > ADODB.Connection::Properties collection in ADO.Net?
>> >>
>> >> More pertinently, why on earth are you using ODBC...?
>> >
>> > And what, pray tell, should I be using?
>>
>> ODBC was superseded thirteen years ago by OleDb:
>> http://msdn.microsoft.com/en-us/library/ms810892.aspx
>> http://database.ittoolbox.com/docume...vs-oledb-18150
>>
>
> I knew about OleDB. Wasn't ADO built open OleDB as a way of shielding VB
> programmers from the complexity of OleDB? The real reason I have been ODBC
> with ADO is that I am lazy. I cannot remember the names of the providers
> in
> which I am interested. I have to look them up each time.
The ActiveX Data Objects (ADO) are simply API's to the particular OleDB
Provider. They give a developer a common way to work with different
providers.
>
> In this particular case, my program will conect to an Oracle database, but
> I
> don't have Oracle here. I'm too lazy to make a trip just so that I can run
> my
> program (to convert an XML file into records in a table) against an Oracle
> database. There does not seem to be a .NET provider for MS Access, and
> even
> if there were, I would have to write different code depending on the
> database
> that I was connecting to:
>
> dim cnn as JetConnection 'or something like that
> and change it to
> dim cnn as OracleClientConnection
You're not quite correct here. It's much easier than you percieve it to be.
To utilizie the provider for Access just use the types in System.Data.OleDB
namepace (the OleDbConnection, OleDbCommand, etc.). Here's a link to get
the Oracle provider:
http://www.oracle.com/technology/tec...net/index.html.
You can absolutley create one set of code that will handle either database
being used and it's called creating a Database Provider Facotry. I've
posted a link in my other comment about doing it.
> You haven't answered the original question. Can you try this one instead:
>
> If I use the ADO.Net provider for OleDB, and I allow the user to select an
> OleDB provider from a list of providers installed on his PC , will I be
> able
> to display that provider's login box and let the user connect, and then
> save
> the resulting ConnectionString to be re-used in the future?
Again, OleDbProviders do not have a user interface. There is no such thing
as this login box that you are asking about.
What you've got to understand is that Open DataBase Connectivity was a
WINDOWS feature that allowed a developer to create a Data Source Name (DSN)
that was specific to a particular SYSTEM. To aid the developer, Microsoft
created a UI for creating these DSN's, wich was the ODBC Manager, available
via Control Panel. The problem with this approach was twofold...First, the
DSN's are machine-specific and need to be set up identically on each and
every machine that the program was to run on. Second, the whole ODBC
architecture was an extra layer built on top of the database driver that
actually was performing the work. This was like having a middle-man talk to
another middle-man to talk to your database. It made ODBC versitile, but
also slow.
Object Linking & Embedding DataBase (OLEDB) Providers replaced ODBC and
solved both those problems. When using OLEDB, there is no UI to create the
DSN to talk to the database driver. And that means there's no more DSN's
either. And that means you don't have to run around and set this stuff up
on each pc which will run the application. With OLEDB, your programming
code talks directly to the database provider, cutting out the extra middle
man and making the process much more streamlined, which results in superior
performance.
Because OLEDB Providers are "talked" to exclusively through your program's
code, there is no system "login" boxes or any other UI to get in the way.
You simply code your application to use a particular provider and that's
it.
You have mentioned that your application will make use of Access and Oracle
and want a coding solution that will accomodate both. That's not a problem.
DataBase Provider Factories are a relatively straight-forward way to solve
that issue. If you need the end user to supply their credentials, then just
prompt them for that informaiton and use it in your connection strings.
One piece of advice, and don't take this as an insult because it's truly not
meant that way....To work with .NET effectively, you've got to understand
that VBScript and many of the programming paradigms that came before it are
dead, as it relates to .NET. Forget VBScript, it 100% irrelevant to how VB
..NET is written and functions. Forget ODBC, it's archaic and doesn't
perform nearly as well as OleDb.
Good luck!
-Scott
>
> <snip>
>
>> These days, there are native .NET data providers for all major databases,
>> and these run rings round OleDb in terms of performance and
>> manageability.
>>
>
> I would certainly hope so, but to be honest, I have never seen Microsoft
> release a new product that was more efficient than the previous one.
> Anyway,
> I will take your word for it.
>
>> Generally speaking, there is no good reason for using ODBC if OleDb is
>> available, and no good reason for using OleDb if a native .NET data
>> provider
>> is available.
>>
>> Especially with SQL Server...
>>
>>
>
> Your point is well taken, but as I said earlier, my app needs to work with
> 2
> databases.
>
> Regards,
> John Brown.