Can I get my Database code? - c#

To explain, I have a database db_Name. Over the course of development of my program, the parameters of this database has changed through the use of MySQL Workbench. Unfortunately the hard-coded construction of the database in my program has not been kept up to date.
Is there a way that I could return the code for the construction of my database in the latest version?
To explain: I'm looking for this code:
Table_Name_1(Tbl_Id CHAR(25) NOT NULL AUTO_INCREMENT, Field_1 CHAR(25) UNIQUE, Field_2 INT, PRIMARY KEY(Tbl_Id));
Table_Name_2(..........
etc.

If you need SQL for database structure - you can backup your database to *.sql file without table data.
You can do that in MySQL Workbench.
Step-by-step guide:
How to take MySQL database backup using MySQL Workbench?
You can also use SHOW CREATE TABLE TableName sql statement to return database structure as data view.

Related

How to insert bulk record in SQLite table from result of a SQL Server query through C# or directly from database

I have thousands of records from a SQL Server 2014 stored procedure result set, and I insert them one by one into a SQLite DB table through C# code, which takes around 4-5 minutes. I need to reduce this time.
I am looking for something like:
insert into 'sqlite_table'
select *
from 'sql_server_table'
Any answer with C# code or anything direct from SQL Server script can be helpful
On your C# Code. Use SqlTransaction to fasten the insertion of records from one table to another.
I Have done same thing in Sql Server to MySql. For that first I stopped the AutoCommit (Set AutoCommit=False). After the query run the commit command. It gave me good performance. You can try the same if it works for you.

FoxPro DBF Table Into MySQL Table C#

I'm attempting to select the columns I want from a FoxPro DBF table and insert them into a MySQL table, preferably (if possible) creating the SQL Table on the fly from the columns I've chosen.
I've had a look and I unserstand this is probably going to be built around the SQL Statement "SELECT INTO FROM" but I'm unsure how I would do this, especially programatically within C# and especially scenes as I'm going from DBF to MySQL, not MySQL to MySQL.
Can someone advise on how I would do this within C#? I already have an OleDB Connection setup as such;
public void runDbfCmd()
{
string constr = ConfigurationManager.ConnectionStrings["dbfString"].ConnectionString;
using (OleDbConnection dbfCon = new OleDbConnection(constr))
{
try
{
dbfCon.Open();
OleDbCommand dbfCmd = new OleDbCommand("SELECT INTO STATEMENT HERE");
dbfCmd.ExecuteNonQuery();
}
catch (OleDbException ex)
{
throw ex;
}
finally
{
dbfCon.Close();
}
}
}
As you can see I'm stuck on how to build the command and whether or not this will work how I would like it to.
If you want to do it on the FoxPro side by sending SQL statements there, the FoxPro statement Select ... From ... Into ... as you proposed would probably not do what you want because it would create a FoxPro "Into" destination, i.e. a DBF table or a "cursor" or an array.
Whereas on the FoxPro side, SQL Insert Into ... Select ... From ... would be able to do what you want if the "into" destination is a Visual FoxPro "CursorAdapter" object, or a "Remote View" (residing in a FoxPro "database" DBC), which both could be connected to a MySQL database via ODBC, and the former also via OleDB. If you do not have either of them already prepared on the FoxPro side, you would need a VFP development environment to create them because not all FoxPro commands and functions are supported by its OleDB driver, see also "Supported Visual FoxPro Commands and Functions in OLE DB Provider" https://msdn.microsoft.com/en-us/library/80x51c04%28v=vs.80%29.aspx
Assumed you do not have VFP, perhaps it would be easier to do most things on the C# side?, like sending "Select ... From ..." statements to the FoxPro DB, retrieving and intermediately storing the result on the C# side, and then send "Insert ... Into ..." statements to the MySQL DB, and also "Create Table ..." statements if you will
What you are looking to do can not just be done from C# from a VFP database and directly into SQL in one statement as you are attempting. Reason being. You can't have one connection pointing to two different database types... VFP and MySQL respectively.
What you would need to do is...
Open Connection to VFP,
select * from YourTable and fill into a C# data table...
Look into OleDbDataAdapter.Fill()
Once the data has been pulled from VFP locally, you can then open a connection to your MySQL Database, create the table, and then for each row in the localized VFP table, insert into the MySQL.
Alternatively, once local in C#, you could possibly dump to a standard format that MySQL can do a bulk insert into.
But again, you can't go directly from one to the other.

Copy data from postgres to sql server with very similar schema

I have data in postgres that I need to programmatically move to sql server on a scheduled basis. The tables have the all have same schema and the tables are not very relational (no foreign keys), but I think I can just use WITH NO CHECK if there are.
I have ADO.Net connectors for both servers, so I think I can just select from the postgres to a DataTable and then INSERT INTO the SQL SERVER tables. However, I'm a little concerned on performance.
My question is how hard would it be to use the Postgres COPY command to export to say CSV, and then use bcp.exe to import the CSV into SQL SERVER. Does this sound like the way to go? I can see this needing to scale to ~750k records being copied per schedule.

how to make Mysqldatabase converter in c#

i want to make Mysql Database converter that can obtain the data from Database A to database B.
both database have same table and column.
how i can make them using c#.
are anyone show me flow or how i can do it
Try the following steps:
Execute the query to retrieve the data from database A;
For every record retrieved, insert a new record into database B.
This mechanism can be automated by automatically creating queries and inserts. To retrieve the tables and fields in a MySQL database, refer to the INFORMATION_SCHEMA tables in MySQL. Using the information retrieved from these tables, you can automatically construct the required queries and migrate an entire database automatically.

Using MySql stored procedures for .NET Data Access Layer

I'm using .NET 2.0 and/or 3.5. Weird thing is, everytime I add a query, whether via TableAdapter or a plain query in a Dataset, using a MySQL stored procedure (whether be a select, update, insert, delete), the wizard doesn't finish (the dialog suddenly disappears, I'm back to designer mode and the query isn't added to the tableadapter or dataset form). Is there a special formatting required for MySQL stored procedures, or a workaround for MySQL stored procedures to work?
I'm using
MySQL 5.1.33
portable XAMPP 1.7.1
PHP 5.2.9
Apache 2.2.11
phpMyAdmin 3.1.3.1
I was having this same thing happen. The fix for me was the following: One of my parameters for the stored procedure was 'filter'. I changed it to 'p_filter' and the issue went away. The issue that I am still dealing with is on the last screen of the filter I get:
you have an error in your sql syntax; check the manual that corresponds to your mysql server version for the right syntax to use near 'NULL' at line 1
I brought in a stored procedure that doesn't accept a parameter and I have no issues with creating the TableAdapter using the dataset wizard.

Categories

Resources