I've been reading "Apress - Introducing Visual CSharp 2010" the last 2 weeks and wanted to write my first app which include a connection to an access DB.
i found an article explain how to do so and in this article i found something that i dont underst in the example that was given :
- Code
using System.Data.Odbc - Code
OdbcConnection DbConnection = new OdbcConnection("DSN=SAMPLE_ISAM") - Code
DbConnection.Open() // so far so good - Code
OdbcCommand DbCommand = DbConnection.CreateCommand();
please thanks

Jaish MathewsRank #225 · 11K reputationPosted Jan 16, 2011, 6:06 AM EST
Once you go to the definition of CreateCommand() in .NET framework, you will see below lines which saying this method will return a type of ODBCCommand
// Returns:
// An System.Data.Odbc.OdbcCommand object.
public OdbcCommand CreateCommand();
Diego21 reputationPosted Jan 16, 2011, 6:19 AM EST
//Here you create a way to acess the DB
OdbcConnection DbConnection = new OdbcConnection("DSN=SAMPLE_ISAM");
//Here you open the connection, if it works, else you will got a exception
DbConnection.Open();
//Here you create an object which you will use to send commands to the BD
//this object use the previous connection, but there's a method in DbConnection that //create this command for you, so you only job is create the variable and call the method
OdbcCommand DbCommand = DbConnection.CreateCommand();
I hope help you.
Sam HobbsRank #107 · 20.5K reputationPosted Jan 16, 2011, 9:34 AM EST
Note that you should call methods such as that within a try/catch block and if your book does not explain that then it is not a good book.
In fact, ODBC is older technology and most new development don't use it. You should use ADO or direct calls to the database; for now, just learn ADO. The book teaching ODBC is probably not the best book. I suppose you can go ahead and learn ODBC but just understand that you are not likely to use ODBC; it is better to use ADO. Net.