Starting From Scratch - What SQL database should I use with Visual Studio? - sql

I recently got a new primary computer. On my old one, I was working with MS Visual Studio 2008 (or maybe an older version - I can't remember now). I had managed to get SQLite working with it and was in the start/middle of building an application.
On the new computer, I now have MS Visual Studio 2010. I have had problems getting SQLite to work with it. Honestly, I haven't tried super hard yet, because I realized I pretty much want to completely redesign this application anyway and it got me thinking... do I really want to use SQLite or some other SQL? MS SQL (or is it called SQL Server)? MySQL?
My end goal is to have an application that can be installed by the user with one .msi file and the user should not have direct access to the database (although at this stage, that is a secondary concern).
It seems like MS SQL / SQL Server is the easiest since it's also an MS product.... Would love some opinions!
(along with the opinions, I'd also love to be pointed to current instructions... I'm a programmer, I'm not a "coding environment setup" person and have always struggled with this. All I want is to get in there and write my application!)
Thanks in advance!
-Adeena
PS... I'm currently working with C# and would prefer to stick with it, but could easily do this in C++ (I'm fluent in all the flavors of C) if that makes a difference with the database.

SQL Server would be a good choice by the sounds of what you're after. Try the express version - it's free, good for development and prototyping and integrates really well with Visual Studio.
The SQL Server Management Studio tool is excellent. I use this to create the databases I need and then use Visual Studio to manage them (saves switching windows and running both applications when you're working in VS all day anyway). I used to have my issues with the old Enterprise manager software but things really seems to have stepped up for SQL Server 2008 and the new management studio.
Like the title of your question suggests, you're wanting to use this with Visual Studio. If you decide to do use SQL Server then you should:
Download the express edition
Download SQL Server management studio
Create a database
In Visual Studio - click View -> Server explorer -> right click Data connections and add connection. Select MS SQL Express and choose localhost as your server. You can then select the database you created using the management studio.
There you have it - integration with VS.
You say you're using C#.Net - well SQL server and .Net go hand-in-hand. Obviously you can hook up to other third party databases but SQL was really made to work with this stuff. It's a powerful database engine and will do everything you'll ever need as well as being well supported by Microsoft and the wider community.

If your final goal is to have hands-off single-click installation then I don't think SQL Server Express is your best bet because it's not a file-based embedded database. It's a great db and very easy to work with, but when it comes to deployment still takes some installation effort. You could try one of: SQL Server Compact Edition, SQLite or Firebird Embedded.

SQLExpress is free and for development purposes is pretty much interchangeable with the full SQLServer
http://www.microsoft.com/express/Database/

SQL SERVER seems to be the logical one.

Related

Database reverse engineer installation

I have an existing database (SQL Server 2008 R2), and my goal is to have a project that can install the same database as I already have.
i.e the project will read the schema and the data, and will be able to duplicate the existing data and schema.
This tool needs to save the database information to disk so I will able to install the database on different machines.
Can I do it with Visual studio 2010 database projects?
Is it a simple task?
(The reason I am asking is that I already have such a project that installs my database, but this tool is very old(~2000).
That old project is one big mess, it has C#, java, sql, batch files and some 3rd party tools and has many more capabilities than I need for my current product..)
Thanks.
Use SQL Server Management Objects (SMO) to create a snapshot of your source db and then restore it to the target server.
More on SMO here: http://msdn.microsoft.com/en-us/library/ms162169.aspx .
A nice tutorial here: http://www.codeproject.com/KB/database/SMO_Tutorial_1.aspx
The easiest way is to backup using SQL server management studio. Then move the backup file to the second server and there restore it with SQL server management studio. If you need SQL code to do it (instead of GUI way), just drop a comment...
This codeplex project has a basic library that does that if you like to roll your own and has two sample projects for migration/comparison tasks.
http://dbschemareader.codeplex.com/
Also the commercial option is to use Sql Redgate's tools. They are expensive but worth every penny if this is a mission critical database. On the otherhand, if you are just using a db as an alternative to a file, say in a embedded scenario, it might be hard to justify such an expensive tool.
Have you tried DBSourceTools ? http://dbsourcetools.codeplex.com
It is an open-source database versioning tool that will script out all database objects and data to disk, and then re-create the database on another machine.
It has all of the features that you are looking for.

Project using two different versions of SQL Server

I am a junior developer and about to get my feet wet in my first "real" project. However we are trying to figure out a way to set everything up as the current developer lives out of country.
I was told to install certain programs, subversion clients and SQL Server 2000.
It does not seem that SQL Server 2000 can be installed on Windows 7. Are there inherent issues with me developing in a higher version of SQL Server like 2005? Is there an issue with stored procedures that can not be properly translated from on SQL Server version to another?
Again, I'm fairly new at this; please let me know if this is just a bad idea, impossible and any other guidance you can provide.
There are many features in newer versions of MSSQL that were not there in 2000 (multi-row inserts, newer hashing algorithms, and VARCHAR(MAX) to name a few). If you're using SQL Server Management Studio, it will not check these differences for you, even if you are connected to a SQL server 2000 database - it automatically uses 2008 rules for its syntax highlighting. Because of this it's easy to accidentally write code that's not 2000-compatible.
As far as getting 2000 running, if you have the install disk for an older version of windows, you could run a VM (http://www.microsoft.com/windows/virtual-pc/) and install the database server there. If your company has a separate development environment, you could create a copy of the production database to work off of as well.
The newer versions of SQL server bring new language and database features, if you write something using a feature that is available in SQL 2005 and not 2000 i.e. PIVOT then when you try and promote this to live then it will just get a syntax error.
There is no translation, if you went back in time 11 years, you'd still speak English you'd just get an odd look if you talked about 'Tweeting'.
You can set the database compatibility level to an earlier version for the specific database you are working on. This will stop you using the more modern features.
For the most part, you won't run into issues is you're simply running standard stored procedures and SQL statements.
However, there are several things that might not work properly if you're not in sync. SQL2005 was a relatively major upgrade and instroduced quite a bit of new functionality.
I don't know what you've got for available resources - dollars, etc, but if you have an MSDN Subscription at a level that provides you access to operating systems, then I would strongly recommend setting up a virual machine with an older version of Windows using your MSDN licenses, just to keep things on an even playing field.

Change of code if Database is changed (form Access to SQL Server)

I am trying to migrate from Access Database to SQL server database. Do I need to make changes (for saving, reading, deleting etc. data) to my code as well?
I understand I need to change connection but what about code?
Thanks
Furqan
For the most part, Access SQL Queries are very similar to SQL Server Queries. Therefore, unless you're using Access-specific constructs such as Val, CInt, etc in your queries, you can safely migrate to SQL Server.
It is recommended though, that you thoroughly test the program after migration lest you run into 'strange' errors.
I'm sure the conversion will require some time and troubleshooting. For one, Access through version 2007 uses VBA for the back-end code and SQL Server's programming is quite different from VBA. Developer's transitioning from Visual Basic 6 (very similar to VBA) to VB.NET ran into quite a few challenges.
Also, keep in mind that SQL Server is best used as the back-end storage engine. The user interface is typically written in a .NET language using Visual Studio. SQL Server (at least through 2005 -- I haven't used 2008) doesn't have user interface components like a File Open dialog box.

Access vs SqlServer for a Simple Database

I am currently developing a very simple database that tracks people and the company certifications they hold. This db will need to store letters of certification as PDF files. I was asked to develop this in MS Access, but I think it would be better to build it in SQLServer and use Windows Forms to build the interface. This app will need to be accessible from a public location like a share drive.
My question is, would it be better to do this in SQLServer like I think, or am I full of it and my boss is right on the money? Or are we both wrong?
A good alternative to Access which I use a lot is SQL Server Compact (SqlCe). This is a completely different product than SQL Server Express/Standard/etc. It is an in-process database like Access, it does not run as a separate process or service.
It is free
Full ACID support
Supports multiple connections
Full transactional support
Referential integrity (including cascading updates and deletes)
Locking
T-SQL syntax and SQL Server data types (same API as SQL Server)
Small footprint (~2 MB)
Easy deployment (supports ClickOnce, MSI, XCopy, etc)
Database is contained in a single file you can move around
Supports ADO.NET, LINQ to SQL, LINQ to Entities.
This is an extremely difficult question, without an understanding of the scale of the application. In my opinion, I wouldn't touch Access with a 33.5 ft pole.
Benefits of Access:
No dedicated machine necessary
No problems with portability
Benefits of SQL Server
Better SQL compliance
Better management control
Are you planning to store PDF files in the DB? If so, why?
I choose SQL Server.
An application built on SQL Server will be more robust and support more users than one built on MS Access.
An application built on MS Access can be easier to debug because there is a lack of a server, lack of significant multi-user support, and the entire database sits in a single file on disk that is easily copied around.
Given that, in almost every case, I choose SQL Server over MS Access.
Argh, do the world a favour & use SQL server. Express editions are free, and plenty powerfull enough for your requirements. You can even continue to do the form/report/UI design in Access if you so desire, it can hook up to SQL Server very easily and transparently.
Pros of SQL over access: concurrency, scalablity, reliabiliy, less future developers trying to hunt you down and kill you.
I would almost never use access for a db if I could avoid it, now that SQL Express exists.
If I were you I'd go with what some of the others said and use SQL Express:
http://www.microsoft.com/express/sql/default.aspx
You get all the benefits of a true SQL environment FOR FREE! You can even use the SQL Management Studio as well as leverage Reporting Services (if you download the advanced pack). Download link below:
http://www.microsoft.com/express/sql/download/
Which edition of SQL Server 2008 Express is right for you?
SQL Server 2008 Express is available in the following 3 editions (each is available from the Install Wizard):
SQL Server 2008 Express with Tools
SQL Server database engine - create, store, update and retrieve your data
SQL Server Management Studio Basic - visual database management tool for creating, editing and managing databases
SQL Server 2008 Express with Advanced Services
SQL Server database engine - create, store, update and retrieve your data
SQL Server Management Studio Basic - visual database management tool for creating, editing and managing databases
Full-text Search - powerful, high-speed engine for searching text-intensive data
Reporting Services - integrated report creation and design environment to create reports
SQL Server 2008 Express (Runtime Only)
SQL Server database engine - create, store, update and retrieve your data
SQL Server 2008 Management Studio Express (SSMSE)
Free, easy-to-use graphical management tool for configuring, managing, and administering SQL Server 2008 Express. It can also manage multiple instances of the SQL Server Database Engine created by any edition of SQL Server 2008 including Workgroup, Web, Standard and Enterprise.
Note: This separate download is designed for customers who have previously installed SQL Server 2008 Express (Runtime Only). If you are looking to download SQL Server Express and SSMSE for the first time, please download the SQL Server 2008 Express with Tools from the Install Wizard.
Access, to me, is really a hobbyist tool or for REALLY basic local projects at this point that just hasn't been phased out yet. I'd definitely look to using SQL Express, plus it makes it that much easier to upgrade if you get beyond the 4 GB database barrier in the future.
Go with what you have the best skills in - Access is great for a variety of projects andit can scale really well if you know what you're doing. Conversely, a bad programmer could do an app in Win Forms and SQL Server and produce a badly performing monster.
I personally would go with SQL Express and a Win Forms or ASP.Net front-end as experience shows that these small projects can easily develop over time in to much bigger applications than was originally planned and a well structured database built on SQL Server can scale up more readily to more users if needed.
Hard to say without understand the environment. It could be that all users have Access, but no desktops have .NET Framework (although this would be hard to believe). Maybe all their applications are on Access and that's all the developers and users there know.
Given all that nonsense tho, You ought to use SQL Server Express 2008 and Visual Studio 2008 Express. Hope I don't get you fired. :)
If the application is, as you said, a very simple database, that's what access is precisely for, creating simple databases. You can write both the database and the application forms within the same environment and users won't need to get anything installed.
Be careful though with concurrent access to your application. If you go for the access solution, multiple users won't be able to use the application at the same time. If you want this to happen, you will need the database and the application being apart. This doesn't mean that the DB needs to be SQL server, you can still use Access as your database if you don't require the power of a more complex engine.
EDIT: Just read on a comment that you are planning to have 10 users and less than 1000 records. FORGET about SQL server, you will be wasting your money. No matter if you decide to go for a simple all-access solution or for a distributed web application or desktop app with remote storage, Access is hundreds of times more powerful that what you need. Even for the "toy-ish" engine that access is, you are not using a 1% of it.

What is a good framework for Database Migrations that is compatibile with SQL Server?

I've been spoiled by ActiveRecords. So I'm on the lookout for migration system that can be applied to SQL Server, and either is executed as Java application, or a Win32 Executable. (Of course further compatibility with other DB's and host OS's is welcome.)
The real desire is having a clear schema change application with roll back, ideally in something nicer then SQL so it can be DB system agnostic.
The hitch I've found for alternatives that are Java based, is lack of clean support for the Microsoft JDBC.
Looking forward to any suggestions.
Check out Ben Sheirmans excellent post on the topic:
http://flux88.com/blog/net-database-migration-tool-roundup/
I tried Tarantino and it worked OK, but you're still locked to sql scripts for sql server.
/Anders
Try Mite. I wrote it and have been using it for years successfully.
https://github.com/soitgoes/mite
If you turn on "Auto Generate Change Scripts" then Sql Management Studio will generate the sql that you can save into your mite file. No more writing migrations just let Management Studio do it for you! Then if you ever need to custom craft something to alter data you can simply do that in sql and save it to a migration.
Let me know what you think.