What is the best way to use a Database in an Open-Source Program which I want to publish on GitHub?
I've had a problem with publishing my programs on GitHub because you were able to see the Connection String. That allowed you to edit the Database how you wanted to. Is there a way to encrypt the ConnectionString when I upload it to GitHub? Is there another way to solve this problem?
Encryption is only as reliable as the way you store the key, wich would have to be as public as anything else used in the code. The requirements of Secrecy and publishing on GitHub are inherently at odds.
One way would be to store stuff like the connecting string in a configuration file that you do not share on github. Or use a local Network only Database with default User values, wich do not help any attacker on your Production Systems.
If for some odd reason access to the same shared datasource is required across all compilations/installations, you could hide the Database behind a WebService whose code you do not share. As the programm only needs to worry about accessing a WebService, you would not need any DB values. Or even wich DB is used in the backend.
Related
I have a WPF app. I need to do something so that users can share their databases localy (without internet). For example: "User-1 launch the app and adding some information to DB, after that user-1 downloads his DB to USB and gives it to user-2. User-2 succesfuly put DB from user-1 USB and easily launchs it with the same app on his PC". Can this be achived with EF/EF Core? Or what i need to use to achive that?
Though it sounds as a very bad practice, but maybe you have good reasons for this.
You could use LocalDB, which is an very small sql package which can read directly from the .mdf database file without having to 'setup a sql server';
https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/sql-server-express-localdb?view=sql-server-2017
Or like the user CodeCaster mentioned, use SQLLite. Which also reads and saves to a file locally;
https://www.sqlitetutorial.net/sqlite-tutorial/sqlite-export-csv/
Entity Framework is a database-agnostic data access library. This means that it doesn't care where your database lives.
If you want a portable database, look into SQLite.
Is that possible to create a database that's already included in the project and without opening the database application?
Because, I have to publish the system that I made.
I think that you might be interested by in-memory databases, It is treated here.
You could also have a remote database, giving the capacity to anyone with your application and appropriate credentials to connect to it.
If you are looking for a other alternative, you could also export the Scheme and/or Data of a database to a portable .sql file.
I have two sql servers installed on my computer (SQL2008 EXPRESS) and also SQL2008 that comes with the specific software that we are using.
I need to make a service that runs all the time and at a specific time updates the non existing records in the SQL2008 EXPRESS from SQL2008.. can you suggest a way of doing this?
Currently the best thing I got is making a local copy in excel file, but that will result 365 excel files per year which I dont think is a good idea :)
p.s. sorry if my english is bad :)
You don't have to hand-craft your own software for that. There are 3rd party tools like OpenDbDiff or RedGate dbdiff to do that. These tools generate the differential sql that you can apply on your target database.
I'm confused when you mention Excel. What would Excel have anything to do with moving data from one SQL database to another?
The short answer is, if you need a C# service, then write a C# service that copies the data directly from one database to the other. The problem that you are trying to solve is not very clear.
Having said all that, and with my limited understanding of the problem, it sounds like what you need is a SQL job that is scheduled to run once a day that copies the data from one server to the other. Since it sounds like they are on separate instances, you'll just need to set up a linked server on either the source or destination database and either push or pull the data into the correct table(s).
EDIT:
Ok, so if a windows service is a requirement, that is perfectly acceptable. But, like I mentioned, you should forget about Excel. You wouldn't want to go from SQL->Excel->SQL if you have no other reason for the data to exist in Excel.
Here is some information on creating a windows service:
Easiest language for creating a Windows service
Here is a simple tutorial on accessing SQL in C#: http://www.codeproject.com/Articles/4416/Beginners-guide-to-accessing-SQL-Server-through-C
If you want a more formal solution (read: data access layer), I'd point you toward Entity Framework. The complexity of the project will probably be the driving factor on whether you just want to do SQL statements in your code vs. going with a full blown DAL.
I have a server application and client application that the database is shared within a network, What I want to happen is that when the client application inserted/updated/deleted data from a specific table I want the server to be alerted and run some code on it.
How can I possibly achieve this? Any ideas will be a big help! thanks :-)
Use a trigger for push notifications, or keep lastModified information to check for pull notification.
You probably want the former,
edit You can use sys_exec('program') from https://github.com/mysqludf/lib_mysqludf_sys to call an external program from a trigger. Just use that to call whatever server code you have.
Examples and setup instructions can be found via google. e.g. http://bernardodamele.blogspot.com.au/2009/01/command-execution-with-mysql-udf.html
You didn't say what type of database you were using. If you were using MS SQL Server, I'd suggest having a look at their StreamInsight which lets you write "adapters" that deal with data in real-time as it is saved.
I don't know if you'll be able to access/incorporate that in your existing server application though. But depending on what you're trying to achieve, you might not have to.
I just started working with SQL and now what I need is to make a database for my C# application which will save user names and passwords. Think of it like a password reminder.
Anyway, what I think I need to do is: I need to create a SQL database which will the application only use to save data. It should not need SQL Server to be installed on the machine.
I searched over the internet but no result, all of them require the use of SQL Server, please could you just provide me the steps to do so, or any resource and thanks a lot.
You need to decide how you want to save your data. You can save the data in an XML file, a plain text file, or anything else.
The reason you're seeing so many examples of people using SQL is because relational databases have already solved a lot of the issues you're likely to run into when storing and retrieving data. That means in most cases, it's much easier to use an SQL database (even a lightweight embedded one) than to try to come up with your own library for retrieving and saving data.
A note about saving passwords
Bear in mind that any data you save on a client's computer is going to be accessible to that client. You can use tricks to make it very difficult for someone to get to that data, but there's nothing your program can do that a clever hacker won't be able to mimic. The only way to avoid letting users see the stored passwords would be to make the user provide a "master" password that gets converted into a key that is used to encrypt the other passwords. This way, only users that know this master password would still be able to get the stored data.
Storing data in a relational database is not sufficient to prevent users from accessing that data.
You could use SQL Compact ( http://msdn.microsoft.com/en-us/data/ff687142 ) to avoid installing SQL Server.
You could also go for sqlite.org.
Your requirements of "I want a database" and "I don't want [database]-server" are difficult to match.
If you have a database without a database-server, you have a lump of in-accessible data.
If you want to use a SQL database, you will need a SQL server. Or, you will have to re-implement one in order to use the database.
There are a number of small, open-source SQL servers available. I've worked with HSQL.
you might want to take a look at the SO question SQL-lite vs HSQL-db.
If all you want is one file that can't be read easily, try encrypting the data, and use either text or XML files for storage.
You do need a database to be installed on your computer if you want to use SQL to query the data. It need not be SQL Server, but definitely some kind of database. You can download MySQL, Sql Server Express or any of the free database products available out there.
Once you have that up and running, querying the database from c# is fairly simple and it may be easier for you to follow this tutorial, with has similar functionality to what you need.
You could always use a CSV (Comma Separated Value) file as your "database" I found a link that could help you with this Query CSV using LINQ C# 2010
EDIT: When it comes to security, you can always use something like MD5. It can turn a password into a an irreversible hash. This way no one will ever be able to see others passwords