Add database to C# application as SQL Server or Windows Forms project?

Hi, I'm new to Visual Studio, C#, and SQL Server, so wanted to ask what might be a rather basic question:  I'm using Visual Studio 2013 Express to develop a desktop Windows Forms application which which uses and will be deployed with a SQL Server localDB database.  The database will need to be updated periodically, so I'd like to make that as easy as possible.

When I started I wasn't sure I would end up sticking with C#/SQL Server (or revert back to VBA/Access), but I'm making decent progress now and want to reorganize/optimize the projects within my application (I'll have more questions about that in a different thread).

My question is what is the best way to add the localDB database to the application?  The MSDN documentation says to add a localDB in a new Windows Forms project, but from what I've seen it looks like an SQL Server project might be better because my understanding is that it is easier to update databases created as SQL Server projects.   What are the pluses and minuses of doing it both ways?

My inclination is to follow the guidance in the MSDN documentation, but I'd at least like to understand why they suggest a Windows Forms project.  Thanks in advance for any advice.
tmreiterAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongCommented:
>>The MSDN documentation says to add a localDB in a new Windows Forms project
do you have any MSDN link to share with us? In my opinion, it's just an example, perhaps in that particular article to show you how easy we can create a localDB database or connection to a specific database in a Windows Form project. You can establish the connection to a local database using the existing wizard of the connection objects or using the codes purely.
0
tmreiterAuthor Commented:
Sure, here's a link:
MSDN Doc re localDB

I've already got a connection to the localDB but would like reorganize the solution so that the database, presentation layer and business logic are in separate projects within the solution.
0
HuaMin ChenProblem resolverCommented:
Hi,
1. You actually only need one connection string on your C# project.
2. You can try to put this
	<connectionStrings>
		<add name="conn2" connectionString="Data Source=192.?.?.?\your_db_instance;Initial Catalog=your_db_schema;Integrated Security=False;User ID=your_db_login;Password=??????" providerName="System.Data.SqlClient"/>
	</connectionStrings>

Open in new window

within Web.config/app.config file in your project, to ensure the project will work fine with the database.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

tmreiterAuthor Commented:
Thanks, but my question is not really about connection strings, I don't have any problem connecting with the database.  My question is whether I'd be better off adding a localDB as a Windows Forms project, as MSDN suggests, or as an SQL Server project, which seems to offer some advantages for database deployments.  Frankly, I don't understand the advantages/disadvantages or implications of one type of project vs another, and would like to set it up properly.

Hopefully someone can spare 5 minutes to set me straight on this issue.
0
Ryan ChongCommented:
>>I'm using Visual Studio 2013 Express to develop a desktop Windows Forms application which which uses and will be deployed with a SQL Server localDB database.  
>>My question is what is the best way to add the localDB database to the application?

Since, you're going to develop a desktop Windows Form application, you can use the existing control wizards in your C# project to add a connection there OR else you can dynamically create the connection by using the Connection objects that you declare in your codes. Both ways are fine.
0
tmreiterAuthor Commented:
Thanks, but again, my question is not about connections, but the practical differences between adding a database as a Windows Forms project vs a SQL Server project...
0
Ryan ChongCommented:
what do you mean by SQL Server project ?

it's really depends on the nature/requirements of what kind of applications you try to develop, and then we select the relevant project type accordingly.

Do you mean there's an option in VS 2013 Express to create a SQL Server project?
0
tmreiterAuthor Commented:
Do you mean there's an option in VS 2013 Express to create a SQL Server project?
Yes, exactly.  Here is a link with a basic summary of database propjects:
SQL Server Projects

But for localDB database projects, MSDN (see the link in the third post above) suggests using a Windows Forms project instead.  

It sounds like an SQL Server project would make more sense, but before ignoring MSDN's advise I wanted to make sure I wasn't missing something important.
0
Ryan ChongCommented:
Ok... seems I also missed that feature in VS Express (because I never use that feature)

But since you're going to develop a desktop Windows Forms application, my suggestion is just go with the option with Visual C# as your project template and start build your application. This would be the common practice for most I believe.

You NO need to worry about that if you didn't select the SQL Server as your project template. In any case, when you need it, you can create another project with option SQL Server as the template. From the article you had posted it seems that it's more like a project option to fine-tune your SQL Server.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tmreiterAuthor Commented:
OK, thanks, I guess you're right, if I need to I can also use the same DB to create an SQL Server Project.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.