Click here to Skip to main content
15,915,093 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to write mysql insert query that takes all data from datatable
Posted
Updated 26-Aug-12 21:38pm
v3
Comments
pradiprenushe 27-Aug-12 3:31am    
you want to copy all data of one database to another database?
madhu.gone 27-Aug-12 3:49am    
yes
pradiprenushe 27-Aug-12 3:59am    
Why you want this? You want to create backup or what?
madhu.gone 27-Aug-12 4:09am    
my work is two database, one is on server and one is in localhost,and i have to insert many data entry work in day,
so before going to home i have to make dml staments into server Some times server to local host
how its is possible in asp.net
pradiprenushe 27-Aug-12 4:57am    
You should create some patch file with sql query rather than totally copying database. But make sure in patch file query must be written with fully qualified name.

1 solution

If using MySQL, you could write it to a .csv and use :

C#
var bl = new MySqlBulkLoader(connection);
bl.TableName = "mytable";
bl.FieldTerminator = ",";
bl.LineTerminator = "\r\n";
bl.FileName = "myfileformytable.csv";
bl.NumberOfLinesToSkip = 1;
var inserted = bl.Load();
Debug.Print(inserted + " rows inserted.");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900