I am going to need to create a small windows application that stores basic data about people.
The requirements are:
Recruiters go out into the field and gather demographic data about people they talk to.
Recruiters return 'home' and contribute their gathered data into the main database (SQL Server 2005).
This is the first time I have ever done anything like this. So I am just looking for suggestions. I know I want to use C# to build the windows app and don't have a problem using .net 3.5.
I think a good place to store their data would be in a SQL Server Compact Edition database.
That's as far as I am. I mainly build ASP.net webforms, so this is a bit of a departure for me (but that's a good thing).
How would you tackle this? I am especially interested in how I might get the local data into the big database? Does the .net or sql server have any tools that make this easy? Any suggestions and considerations are welcome.
I would start with the Sync Framework. There's even a sample using SQL Compact as an offline data store.
Related
I am developing a Microsoft Kinect game (for Windows) using C# and I need a local database to store information about players and their progress as well as more detailed information on their points and accuracy. I have never used a database within a Windows application and I was looking for some advice on how to do so. I have been trying to use SQL Server because it lets me create a database within Visual Studio. I have been unable to find many resources on how to interact with the database from within the C# application.
I really know very little about SQL Server so I do not know if it is the right choice for what I need. Does anyone have a suggestion for what sort of database system to use? Can you point me in the direction of some good resources/examples on how to do what I need to do?
Thanks so much!
Edit: I should also mention that I do have experience working with SQL.
There are other, more portable, solutions such as SQLite and SQL Server Compact Edition which do not require a separate server installation and are more easily accessed and distributed from within a standalone desktop application.
The usage can be largely compared to an external SQL server and/or Linq to SQL so the actual implementation should not be that hard.
Some interesting links:
How to: Deploy a SQL Server Compact 4.0 Database with an Application
An Introduction to SQL Server Compact Edition
As mentioned in another comment, a simple serialized XML file might also be enough for your use. It's fast, easy and if you don't need to perform any actual database operations but simply save and load everything then it might be more efficient.
Look into using a SQLDatasource and relevant tutorials. This will give you an easy way to get up and running without an intimate knowledge of SQL. Once you have the datasource setup and 'bound' to your database, you can use this to connect your controls (grids,labels,textboxes ect.) to it.
Check this out:
http://www.youtube.com/watch?v=w34BDhDPEEQ
You don't want the fully fledged SQL Server. SQL Server Compact Edition is more appropriate, or there's also SQLite for a non-Microsoft option.
The easiest way to interact with a database from C# is Entity Framework, which ships with .NET 4.5 or is downloadable as a nuget package for .NET 3.5 and .NET 4.
A different, non-relational-database option would be DB4O.
You could use Entity Framework
var player = db.Players.Where(x => x.playerId = id);
var points = player.points;
points =+ 100;
db.SaveChanges();
You could also write CRUD operations against the tables if you don't want to use an ORM
Basicly you will have to make a database with a table, using the GUI of Visual Studio.
Then where necessary in the code, you will have to create a connection with the database using a connectionstring. Then you will have to insert an SQL command using the SQLCommand class and execute it. This requires some knowledge about the SQL syntax, but just search what kind of command you want specifically now and in time you will get the hang of it. Don't forget to close the connection to the database when you are ready with writing or reading data.
I hope this gives the main idea.
Edit: Oh and for this kind of database SQL Server Compact will be enough.
I am current building (in C#) a fairly basic point-of-sale program for a local community in Uganda to use in tracking business at their sunflower seed press. I was thinking that I would need some sort of database (like a SQL database), but I've never set up a database before, so I'm wondering what the best way to do this is. Maybe a database isn't the best way. The program will not have internet access, so everything will have to be done locally on the machine.
I think your first step should be designing out what data you need to store. Build an Entity Relationship Model and decide what your domain model is going to be. There are many different Database Engines out there that you can use that have different features, installation requirements, etc. A database engine can be installed locally, or on a remote machine to connect to. If you're writing a C# app, you'll probably want to use the System.Data namespace. You can use plain ADO .NET, or use something like Linq To Enttiies to help create proxy classes for your data tables.
You can access a SQL database using the same API for queries / record extraction regardless of the DB Engine uses. In some caess, you may need to use a seperate library that provides an implementation (or a better one), as in the case of an Oracle Database and the Oracle Data Access Components. Right out of the gate, .NET works very well with Microsoft SQL Server, but other options would work.
The details of what database engine are not as important as defining a good set of data tables to represent your data.
Yes. If it has lots of data you have to consider using database. Whether you have internet or not, as long as you have local network, you can easily do database.
Set up a database server ( maybe sql)
Do your database and install it on the database server
Do your application and connect to your database through connection string.
You are on the right track to use a database to store data. It is pretty easy to accomplish. Your computer does not need to be connected to the internet.
SQL Server Express Edition is free with a limit of 10 gigs of data. This will probably be much, much more space than you will need.
From C#, use ADO.NET. It is very simple if you know some SQL. Code samples here.
I have worked with Microsoft Access as the back-end of my applications in the past and Visual Studio offers me the choice of copying the database to the installation of the executable that I have created. However, I now want to move onto more complex databases and I figured MySQL was a good start because it's free and popular. I know there may be better options and right now I'm currently only in learning stages so I strictly want to stick with MySQL.
My problem is that I have my MySQL running on my localhost. I have connected to it, ran queries, etc. Now if I wanted to deploy this application to other computers while keeping the database (not web-based) how would I go about doing that? The reason I don't want to go web yet is because I just want to get an understanding without dealing with networking yet. I figured this would be the way to go.
Thank you.
MySQL is not primarily anything. It's a full database as is Oracle, SQLServer, Postgre, etc. that can be used for any application that you feel it applies to.
In your case what you really want is SQLite for "embedded" database needs. The database is represented by a single file that can be opened and queried very similarly to MySQL.
http://www.sqlite.org/
To access the database from your C# code there are many libraries available to you. Here is one I used a while back as an example:
http://www.devart.com/dotconnect/sqlite/features.html
To play around with the data, as you would with MySQL Workbench, there are many front-ends. As an example there's a pretty good firefox addon for this:
https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/
And don't worry, it's extremely easy to use and most of the query syntax will apply to MySQL as well!
I am currently in the process of developing a program and not sure where to go from here...
I am using Visual C# and the DotSpatial frawework in order to do the GIS/GPS side of things but am unsure of what back end database to use.
I have had a look at PostgrSQL with PostGIS and also had a look at MSSQL as this now has Geospatial capabilities.
So what I am trying to achieve is the following with the software:
- The software needs to be used both at the persons desk, but also remotely while using the GIS/GPS side of the system to track the users travelling. (i.e. when locating where they need to go - this is custom data on remote sites). This is relatively easy to do with DotSpatial alone and not DB is needed.
- They have custom forms that capture data (text, lats/longs, photos) while out on site.
- The data needs to be able to sync up with the main database when they are back in the office
- This data needs to be viewable by everyone connected to the system once the system is updated
Ultimately if this can be a type of DMS then that would be great. So I am keeping that in mind as well.
Should I use a seperate DB for the datacapture side of things and something else for the main DB or should I use the same for both? Which one is easiest to configure? I would prefer when deploying the software that the installation goes smootly and dont have to manually configure each machine.
The main server is Windows 2008 Server btw.
Any help or suggestions would be greatly appreciated.
I use PostgreSQL with PostGIS on a daily basis. Although it is opensource it provides very good funcionality and performance.
Check this Cross Compare between SQL Server 2008 Spatial, PostgreSQL/PostGIS 1.3-1.4, MySQL 5-6. This could give you a good idea
I second the recommendation for PostgreSQL/PostGIS. It works very well and is well supported by the community. I would note that OpenStreetMap uses PostGIS as well. Indeed, if you ever want to work with their data you'll be wanting PostgreSQL.
i have just started using visual studio 2008.I am working on c#.
I want to add SQL database particularly LOCAL database (.sdf) to my project and want to use queries which will save data in database and fetch some data from database and which will display and will perform different function.
So, if any body can give me any small tutorial or link that what are various types of databases i can use along with visual studio and and how will i be able to use it.
Any general tutorial will do.
Thanks a lot.
Regards,
Don't use .sdf databases.
I've worked with it but it was confusing. I was not able to use WHERE statements....
Use SQLite instead.
That is THE Solution.
Download SQLite here
Another tutorial
I recommend you the use of SQLite
Not sure why Gergen was unable to perform where statements. One issue I had with Compact edition was that I couldn't create stored procs or views. I don't have much experience with SQL Lite, so I can't give an opinion on that.
If you are doing web based stuff (i.e., asp.net), I found the following series a good introduction to database stuff: Data Access Tutorials
As for what database to use, as long as there's a provider for it, working with it via ADO.NET (or entity framework, or whatever) should be similar. If you are just starting, I'd probably recommend staying with the Compact Edition since most examples/tutorials you'll see will involved SQL Server.
For simple Local SQL database stores, there are quite a few solutions. A good full comparison can be found on from Wikipedia
SQL Express 2008
Out of process, runs as a windows service, supports stored procedures and views and does pretty much everything SQL standard does with few limitations. 50MB install.
Ideal for anything but large SQL deployments.
Loads of how to guides for SQL Express
SQL Compact Edition 3.5 (.sdf files)
In process, the code for accessing the database runs within the same process as your application. Ideal for embedded systems (point of sale, ATM, in-car systems etc...). Microsoft's equivilent to SQLite. Very small install (easy to deploy with app).
Getting started guide for SQL Compact Edition and a load of HowTos to get you going
SQLite
The non-Microsoft answer to an in process database. Pretty much the same functionality as SQL Compact Edition apart from it's a smaller install (300kb for SQLite vs. 2MB for SQL Compact edition), it supports larger database files (32TB for SQLite vs. 4GB for SQL Compact edition).
SQLite getting started article
Connecting to Microsoft SQL Server 2008 from Microsoft Visual Studio 2005 and 2008
http://msdn.microsoft.com/en-us/library/s4yys16a(VS.71).aspx
I've never built anything using SQL Lite so I can't say much for it. I have, however, built several commercial applications using Compact Edition and haven't had any serious issues.
You can't batch commands with CE and the syntax is the same as Sql Server (with many missing features, but the most commonly used features are there and I've never had a problem without a work around of some sort).
I've really only used it as an "offline" database in an application for a company that dispatches repair technicians. The applications run on netbooks and download their data from a MySql database whenever mobile connectivity is available so they still have access to their work when they have no mobile coverage.
Due to it being so similar to SQL Server, Compact Edition would probably be an easier starting point. Since you're using a local database file you probably won't hit the 4GB limit (with very little pruning my mobile databases rarely exceed 20MB) - and if you ARE hitting that limit you may want to consider using a service based database (like Express) instead.