best way to connect to a database?

  • Thread starter Thread starter Jassim Rahma
  • Start date Start date
J

Jassim Rahma

I would like to know what is the best way to onnect to connect to a
database in general which provides you with full functionality & fast
access?


Best Regards,
Jassim Rahma
 
Jassim,

Do you need to connect to a particular database, or do you need to
connect to any database?

If you have a specific database type to connect to, then look to see if
there are managed database providers for that DB. For example, if you want
to connect to Sql Server, then you will want to connect to the classes in
the System.Data.SqlClient namespace.

If you need to connect to any database in a generic way, the standard
classes (data adapters, connections, etc, etc) all implement an interface
(IDbConnection, IDbDataAdapter in .NET 1.1 and before) or derive from a
common base class (DbConnection, DbDataAdapter in .NET 2.0). You can use a
factory pattern to get specific instances of these types, and cast to the
base class/interface. The problem here is that you have to make sure that
the queries that you use across all of the different db providers will work.

Hope this helps.
 
Well, the fasted and most functional is to probably access the database
using low-level database APIs. Unless you want to deal with these APIs, the
only real choice is to use what is in the System.Data namespace. Can you
offer a more specific question?
 
Jassim,

I'd like to follow-up on Nicholas's first question. I'm in the process of
building my very first C# application. I come from a VB background. So my
first inclination was to save the app's data into an MDB database. But after
talking with a colleague of mine and doing a lot of reading I decided that
saving to an XML data file was much better suited to my needs.

If you're in a similar boat then let me know and I can help you out with
some sample code. FYI the ReadXML function works great but I couldn't get
SaveXML to work for my data model ... so I just wrote my own and it was very
straightforward, using Reflection code to cycle through my data model.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

DataGrid row tag 1
populate comboBox from Database 1
Fill many combo in a fORm fROm DB 1
non C# question 2
problem in DLL calling 5
Date Insert Problem in mySQL 2
help with xtraNavBar 1
Form in DLL 1

Back
Top