How can i export from MySQL to MS ACCESS 2007 in c#? Any tutorials?
Regards,
Alexandru Badescu
You can use NHibernate with 2 session factories, load entities from MySQL and persist them to MS Access.
This would help if you will change databases in the future.
Also respects referential integrity
In Access, go to File => get external data, Import, then choose ODBC as your source. You have to have the MySQL ODBC drivers installed first, and in the process you may have to set up a DSN. Once you've connected, you'll see a list of tables and then you can import them. Whether or not this will get the data types correct is an open question.
If this is something you need to do often, then you should set up an empty shell Access database and then import the data with INSERT queries that specify the ODBC connect string to the MySQL database in the FROM clause.
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
We are using SQL Server 2016 and Oracle 11g (in the process of upgrading to Oracle 12c) .
I'm not a .NET developer; therefore, examples will be very helpful.
Our developers are trying to combine data from both MSSSQL (in-house applications) and Oracle (ERP systems) to create a report in .NET (so just reading from both databases).
The developers are adamant they need to install Oracle client on the server hosting MSSQL.
From the security perspective (surface area exposure), we are encouraged to minimize surface area exposure as much as possible. And I found a possible way on this blog. And this blog that seems to suggest creating a function as connection string.
Questions:
Is there not an option in .NET (array, etc) to hold data from either MSSQL and / or Oracle in memory for comparison (using employee id) with another database?
Since it's only a read, is it an overkill to have full Oracle client installed on the server?
How are the experts here if you need to pull data from both DBs?
Thank you.
At some point a machine will have to have the Oracle client. I don't know of a way to connect to Oracle without it.
I can think of two ways to do this. You can link Oracle tables directly in SQLServer. I presume you can then use the SQLServer dialect to query the Oracle table. I'm sure there is a performance penalty for this, especially if joining across RDBMSes.
A second option is to have some sort of table on your SQLServer that has a copy of the Oracle data. Depending on how much data there is or whether or not you retain it, it could be faster than querying the linked table with a join. It could be a permanent table or a temp table. You'll still need to query the Oracle machine and this done as needed or on a schedule.
If you have very little data, you may not even need a table.
You could also have another machine that performs the query of the Oracle DB and moves the data to SQLServer. You wouldn't need the Oracle client on your SQLServer, but on that machine.
I'd look into building a windows service running on a different server from MSSQL server that would utilize the managed Oracle client to ETL data from Oracle to MSSQL server on a schedule which would allow your .NET report to access the report data from one location, your MSSQL server.
I'm working on a program that will work very nicely with a database structure and using mysql. I could easy do this with a common server and common database. However I'm looking for a way to have my client(s) use the program on an offline machine without having to install any database managing software.
Basically I want the installation to set up the necessary tables on their machine and have them fill in the database with information relevant to them. Before I start though I wanted to know if this was possible to connect to and manage a database through a C# application with out installing sql software.
You could consider using SQL Server Compact Edition.
SQLite is another option.
Both of these can be deployed with your application and need no separate configuration.
Yes. It is possible. How to do it exactly depends on the database connection approach you're using. For example, this approach shows how to use DataReaders. That's a very old approach. Modern approaches are recommended to use LINQ to SQL, which can be configured to access remotely by setting up a DataContext to point to an external resource.
Basically, wherever you can define a connection string to connect to a DB, you can make that string point locally or externally. An external resource must obviously be available through some URL in order to connect, of course.
You can not connect to a mysql database without installing mysql.
However you can use in process database like sqlite or Compact SQL. They are not traditional server, but rather a library that keeps the database in a local file.
I am creating an wpf application which gives user an option to backup an mysql db.I want to get this done in C# coding.
I know that it can be easily done using mysqldump, but i am stuck in an scenario where there is no mysql server installed on local machine and the user wants to back up the db located on remote machine.
So here's where i need help or any suggestion how this can be achieved as i will not get the mysqldump on local machine as mysql server is not insstalled.
I also know that back of mysql db is not possible without using mysqldum utility provided by MySql.[did an google over here and didnt found any helpfull post].
What I tried :
I was trying to embed the mysql dump with an application but somehow i was not able to.
What I want to achieve :
I want to create an back up of mysql db even though the user havn't installed the mysql server on his local machine.
EDIT :
Is there an MySqlCommand which backups the db like the ms sql server one
[ BACKUP DATABASE inventory TO DISK]
This is just for the data, not the table structures, triggers, etc: an exporter to XML, see here
Get a list of the tables:
SHOW TABLES;
Get an SQL statement that will create the table:
SHOW CREATE TABLE table_name
Use SELECT * FROM table_name to get the rows and format them like
INSERT INTO (some_field, another_field, ...) VALUES ('one','two',...)
You can try SQLyog's Scheduled backup/Backup as SQL dump to backup remote MySQL database from local machine. If you have installed SQLyog on local machine you can connect to the remote server and backup using SQLyog.
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.