Background information:
I have been building an App that allows users to interact with each other, post comments/images for the App etc and these all information gets displayed on my App's FanWall screen. I am getting users information using their FaceBook authentication through FBConnect.
To update fanwall screen efficiently, I want to have a local SQLite database for my App that contains userId, his profile image, his comments for my App etc. I have all these info in my SQL server database but not sure how to synchronize this info with iPhone's SQLite database.
My problems:
I am using ASIHTTPRequest to query my SQL database and it can return whole table as Array of C# .NET class. The things that I couldn't understand is;
how to parse this C# .NET class using Objective-c to fetch each class object that is corresponds to each row.
I can then update my local SQLite using this object information but what could be best way to update only rows that are changed? Ideally I should be able to get only required rows from SQL server Database so that I just need to insert them in SQLite. I saw this post but not much helpful for my problem. Just wondering if there is any tool out there that can do this synchronization? I can have tables exactly same on SQL Server and SQLite.
Please let me know your thought on this.
Thanks.
I'm working on a similar problem. How to keep in sync a remote database with a local database. Either end could add or update rows. The solution seems to be to keep a column in each table called lastModifiedDate. This column is set on the server so there will be uniform time.
Periodically, connect to the server and request all rows greater than your local lastModifedDate to get updates and adds. Also, when you push your local changes to the server, the server should modify the lastModifiedDate for uniformity.
I haven't seen a framework for something like this.
Related
What is the best way to synchronize my local mysql Database with online mysql Database using C# (Any Other solution except creating mysql Dump locally and than restore it on online mysql server).
You can use FEDERATED Storage Engine locally.
Not saying it is the best but it is easy to setup.
If your MySQL server version is already compiled with federated engine support what MySQL Windows versions seams to have.
The FEDERATED storage engine lets you access data from a remote MySQL
database without using replication or cluster technology. Querying a
local FEDERATED table automatically pulls the data from the remote
(federated) tables. No data is stored on the local tables.
source https://dev.mysql.com/doc/refman/8.0/en/federated-storage-engine.html
But you need to check if your MySQL version supports it and FEDERATED storage engine is actived.
SHOW ENGINES;
Only think is need to make a table copy from every table and make it FEDERATED storage engine.
Best is to make a separated database for it.
Here is a create table example.
CREATE TABLE `T1`(`A` VARCHAR(100),UNIQUE KEY(`A`(30)))
ENGINE=FEDERATED
CONNECTION='MYSQL://127.0.0.1:3306/TEST/T1';
Then you can insert, update and delete from that table
I suggest you to use MySQL Replication feature.
Replication enables data from one MySQL database server (the master) to be copied to one or more MySQL database servers (the slaves). Replication is asynchronous by default; slaves do not need to be connected permanently to receive updates from the master. Depending on the configuration, you can replicate all databases, selected databases, or even selected tables within a database.
You can find more information at the MySQL official website
I have the local database in SQL Server 2014 with four tables volume 1.5 GB. The essence of the program to look for in the database records with the user defines criteria. The program is written and it works fine. We should make sure that the program worked and other users who have not installed the server. How to implement this? Was a idea to serialize the data, but as I understand, it is necessary to deserialize all the data and then look for the right record.
As the comments before me already says i think you have 2 options.
Either ship the database with the client (using Sql Express or other similar solutions). That should work fine and will work without a connection to a centralized server but the size of your client package will be quite big. And if you make any changes it will only be locally, but it seems you only make reads to the database from the client?
But if i understand it correctly you install a sql server for each client, since you mention "users who have not installed the server"? Then you already have the problem with a lot of data needing to be sent out to each client, as well as the problem of updating all databases when the data needs to be refreshed.
Another solution is to allow access to the database from the client. This can work in serveral ways, if all your users is in your doman you can handle authentication based on their domain users and skip the authentication part. Then you would only need to send out the client and skip the installation of a big server and all the data.
If they are not on the domain but still on your network you could add a login on your application to allow access to the database or if you trust all your users you could add a read only account and just hardcode the login for that account.
If you want to access the data outside of a trusted environment you should of course add a separate login for each user to allow access and it might even be a good idea to use an api before the database that handles the requests from the client and then does the search to the database in a controlled manner.
I would personally go with using a centralized database to skip all the work of setting up new users and also have a single point to update when the data needs a refresh, but of course it all depends on where your users are.
I am trying to connect my app to 2 database (Sql Server) in the same time but these Sql Server stay in different place one is a local server and another one stay online and they are the same ,same Tables ,same fields and same data/records so i use LinqToSql to mapping them and i want connect my app to retrieve the data from the server online but when i want delete or add a new record it should do the same operation in both server ,i mean save data on both sql server,so i ask if you have any help about how work out this feature .
Thanks so much for your atttention.
have a nice time.
Cheers
I would suggest that you investigate database mirroring. I'm not sure how (or if) it works in a local - remote setup, but it would be the easiest solution as there is no code involved.
If that doesn't work or you aren't interested in looking at that option, my second suggestion would be to write a seperate service to monitor your local database (independant of your original application) for changes and push those to your remote server. Google SQL Server Change Tracking for more information on this method.
I'm a dektop developer and don't know much about how webhosting work... So please help me here.
currently my app works with MSSQL database which is installed locally on the same machine.
Now I need to go wider and let multiple apps work with the same database over the Internet.
I have a webhosting with CPanel in it and MySQL database.
Please tell me how I can access tables in that MySQL database from my another computers?
Select and update records in that table. Do I have to implement some functionality using PHP to make such requests?
Please advise..
Exporting raw MS-SQL dumps will probably not work if you try to import into mySQL because there are some differences in syntax. There are commercial programs available that will help you migrate data, otherwise it might be better to code a PHP program to export from MSSQL to mySQL.
But your question sounds more like you're asking how to access databases remotely.
.
PHP can do this natively. When you create your link to the database you specify the host. For example: $databaseConnection = new mysqli('username','password','host_ip_address');
If you're coming from MSSQL you may hit some snares.
To allow remote connections on MS-SQL you use the "surface area" configuration tool. You'll probably find that your mySQL database server is already configured to allow remote connections, if not you'll have to take that up with your host (sounds like you don't have your own box).
The next trick is to remember that usernames in mySQL look like this: 'user'#'host'.
cPanel hosting usually has PHPmyAdmin installed. Open it up and look at the user table in the mysql database (the actual database named mysql running on the MySQL server).
You'll see a host column. So if your 'root' user is only set to 'localhost' you won't be able to login as that user from another machine. The wildcard symbol is %. You can read this up here - http://dev.mysql.com/doc/refman/5.5/en/adding-users.html
Of course the same rules apply to mySQL when it comes to users. Don't use your root account to access sub-databases, rather assign new users which only have the required permissions. Also consider using non-predictable usernames. That doesn't really answer your question (sorry) but it's worth mentioning while you're looking at the user table.
So to finally answer your question:
1) login to cPanel and create your database 'foo'
2) Run SQL command:
GRANT ALL PRIVILEGES ON foo.* TO 'secretuser'#'%' IDENTIFIED BY 'longpassword'
Then PHP code would look something like this:
$host = 'ipaddress or hostname';
$mysqli = new mysqli('secretuser','longpassword',$host,'foo');
// look in php.net for error handling
$query = "SELECT * FROM tablename LIMIT 0,10";
$result = $mysqli->query($query);
The reason I put a limit there is because you're probably used to "SELECT TOP 10"
You would have to export the data on your computer into a raw SQL file, and then using a the PHPMyAdmin control panel you could import it. Assuming you are also using PHPMyAdmin on your own machine there is an 'Export' tab along the top. If you click on that you will have the option to export all your tables to a .sql file.
From there you then need to access PHPMyAdmin via CPanel. Once in you can then hit the 'Import' tab and upload your file to get all the data into the database. To interact with the database online you would need to use the inbuilt functions in PHP - the MySQL Reference on PHP.net is very useful. you would then be able to access the database from any computer using the PHPMyAdmin control panel.
I've built a Compact Framework application to be used by delivery drivers. The system includes a WCF Service and SQL database on the server as well as a SQL CE database and CF application running on the mobile device.
Now the question is how to I update all this easily when I release new versions? The problems are:
it may be deployed to hundreds of PDAs
when first installed on a PDA the SQL CE database has to be populated. This can take a while. I don't want to have to do this each time the app is upgraded so I'm going to have to run scripts to update the db schema rather than just replacing the whole file and repopulating it.
the WCF service code will need to be updated
the SQL database schema will need to be updated
I can see solutions to all this but it seems like a lot of work. I thought it may be helpful to get a few tips before I launch into it all.
Thanks a lot
Mark
I've done some projects with more or less the same requierements.
it may be deployed to hundreds of PDAs
I'll recommend to use an updater, within the application. It checks via a webservice the availability of a new version. Download if theres an update. Then run another process to perform the update(This process I only use to run wceload.exe and then reboot the device).
when first installed on a PDA the SQL CE database has to be populated. This can take a while. I don't want to have to do this each time the app is upgraded so I'm going to have to run scripts to update the db schema rather than just replacing the whole file and repopulating it.
Don't include your database as a file for the application, create the scripts and check if the db exists if not create the db.
the WCF service code will need to be updated
I have an update webservice which is independent so the contract wont change. Which receives the current version, authentication and returns if the update is available and the url for the file to download.
You will need two different address to update and keep the other part working.Just perform a redirect in the new version.
the SQL database schema will need to be updated
I hope you mean that you refer to the server backend so I recommend to use views to search for the information.
If you mean to the SQLCE db you can ship patching scripts or plain erase the db and recreate the db.