Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 10th, 2008, 07:37 AM
Authorized User
 
Join Date: Mar 2008
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to vgsgowrisankar
Default Sql vs Odbc Connection

hai i want to connect the sql database to my application . which connectivity is best to connect the sql database. shall i use sqlconnection , sqlcommand , sqldatareader (or) odbcconnection , odbccommand , odbcdatareader.
                                      thank you
 
Old April 10th, 2008, 07:41 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

Might I suggest going to MSDN and then searching for each of those different classes.

You will then see that some of those serve very different purposes, and should be used in different environments.

Rob
The Developing Developer
Currently Working Towards: MCAD C#
My Blog: http://www.robzyc.spaces.live.com
<center>"Nothing can stop the man with the right mental attitude from achieving his goal;
nothing on earth can help the man with the wrong mental attitude".

Thomas Jefferson</center>
 
Old April 10th, 2008, 07:43 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

In order of preference:

SqlConnection
OleDbConnection
OdbcConnection

If you know you will be connecting to SQL Server then SqlConnection will always be the best option.

/- Sam Judson : Wrox Technical Editor -/
 
Old April 10th, 2008, 07:50 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

To give you a head start, the ODBC classes can be thought of as a "catch all" for any database that supports an ODBC driver. For example, you can use the ODBC classes to connect to Sql Server, Access, or Oracle. However, since you have indicated that you are using Sql Server I would suggest using the SQL classes since they are optimized for use with Sql Server.

hth.
-Doug

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
 
Old April 10th, 2008, 07:55 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

I think one of the key benefits (feel free to correct me if I am wrong more experienced guys! :)) of using SqlConnection other Connection providers is that it utilises SQL Servers Connection Pooling.

Rob
The Developing Developer
Currently Working Towards: MCAD C#
My Blog: http://robzyc.spaces.live.com
 
Old April 10th, 2008, 08:06 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Correct. As I said in my post, the SqlServer classes are specifically optimized to be used with SQL Server (additionally there are connectors that are specific to Oracle and MySQL to name a few) so, as Sam alluded to in his post, if a series of classes are specifically designed for the RDBMS that you are using you should use those.

-Doug

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
 
Old April 10th, 2008, 08:14 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Doug,

Yeah I know that you should use specialised classes if they exist, just wanted to make sure that I was not talking rubbish when I said connection pooling was one of them!

Thanks for clarifying :)

Rob
The Developing Developer
Currently Working Towards: MCAD C#
My Blog: http://robzyc.spaces.live.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
ODBC DSN connection atoyot BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 2 December 14th, 2006 06:40 PM
[Microsoft][ODBC SQL Driver]Connection is busy muthumari_p2003@yahoo.com Pro JSP 0 May 8th, 2006 07:51 AM
Need Help with ODBC connection johnjohn Visual C++ 2 December 7th, 2004 01:11 PM
ODBC Connection abilodeau Access 3 September 22nd, 2004 09:05 PM
ODBC connection mishaq SQL Server 2000 13 June 16th, 2004 02:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.