What is the best way to connect to SQL Server

Posted 19 August 2011 - 05:07 AM

I am teaching myself C# using VS 2008 Standard. I have several books I've been going through, and have an idea that I have been taking notes on.
The books I've got differ on the best way to connect to SQL Server 2005. I'm currently reading a book put out by Microsoft (I don't have the exact title now) that was suggested on a previous post. It is a very good book, but being put out by MS it teaches the LINQ way of connecting.
From overall experience, is this the up and coming way to go? I have seen other ways of connecting so I'm not sure.
Most of my planned work will be freelance applications. No degree and being self taught and almost 40 years old I think most corporations will look right over me until I have some provable experience and since most companies will link to a database I want to learn the best way.
Thanks for all your help.

Replies To: What is the best way to connect to SQL Server

Re: What is the best way to connect to SQL Server

Posted 19 August 2011 - 05:37 AM

Note: I answered your question as far as my knowledge is concerned, other more experienced DIC members got to say something here.

I was advised that LINQ is not good for beginners;because it hides the details behind connecting to the database. I don't really know all the methods of connecting to a database. All methods except the LINQ way use the SqlConnection class. And other methods of connecting may use the SqlCommand, SqlDataReader, SqlDataAdapter,DataTable,DataSet classes in addition; Other classes may also be used to connect to a database. I don't really know which is the best. As a beginner I used All of the above classes to connect to a database and to do different tasks. But now I use LINQ too, because now I am moving to becoming an advanced C# programmer.

Re: What is the best way to connect to SQL Server

Posted 19 August 2011 - 05:46 AM

Really there is no "best way" IMO. There are several different ways, but most of the time unless you are getting into the ground floor of a company they already have an established way of connecting to a database.

Now as far as being able to connect to a database, you can use LINQ, Entity Framework, and the old way using a SQLConnection. I'm sure there are other ways of connecting to a database, but those 3 are the most widely used. Personally if you are wanting to go into the corporate world, I would learn how to use SQLConnection, but for freelance I would suggest using Entity Framework.

Re: What is the best way to connect to SQL Server

Posted 19 August 2011 - 06:34 AM

I have used LINQ and an SqlConnection before, and I found LINQ was a lot more involved for setting up, but once it was, it worked like a champ. If you are just starting with connecting to a database, learn how a SqlConnection works before jumping into LINQ.

Re: What is the best way to connect to SQL Server

Posted 19 August 2011 - 01:19 PM

When you get a little more comfortable with what you are doing, there are some really cool tools out there that do alot of the work for you. For instance, this one generates all of the database classes and makes it extremely easy to query and save data for a MySql database.MySql Connector

Re: What is the best way to connect to SQL Server

When you get a little more comfortable with what you are doing, there are some really cool tools out there that do alot of the work for you.

Thanks alot. I'll definately keep hold of that for future referance, but as you hinted at, I want to do it the hard way first. I'm all about cheating when you can, but before you try to cheat, you need to know the rules of the game.

Re: What is the best way to connect to SQL Server

Posted 20 August 2011 - 07:05 AM

Another quick question with regards to this subject. The books I have either referance using LINQ or don't mention db connectivity at all. I've got some C# VS2005 books layin around that might turn the trick. Will the command structure from VS2005 convert to VS2008 with the MSDN library loaded with 2008?
Or does anyone have any suggestions for better reading material that would take me in the right direction?