Click here to Skip to main content
15,894,955 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have web application. i want to transfer data with tables from one database to other database in the diiferent server offline.without use of generate scripts option
how to do plz tell me.

i did the some code:
C#
source = ConfigurationManager.AppSettings["ServerName"].ToString();
           database = ConfigurationManager.AppSettings["DatabaseName"].ToString();
           userid = ConfigurationManager.AppSettings["UserId"].ToString();
           pwd = ConfigurationManager.AppSettings["Password"].ToString();

           string DestinationServer = ConfigurationManager.AppSettings["DestinationServer"].ToString();
           string Duserid = ConfigurationManager.AppSettings["Userid"].ToString();
           string Dpass = ConfigurationManager.AppSettings["password"].ToString();

           SqlConnection dbcon1 = new System.Data.SqlClient.SqlConnection(source);
           dbcon1.Open();

           SqlConnection dbcon2 = new System.Data.SqlClient.SqlConnection(DestinationServer);
           dbcon2.Open();


           SqlDataReader dr;
           SqlCommand cmd = new SqlCommand("select * from tblClientInfo",dbcon1);

               dr = cmd.ExecuteReader();



               while (dr.Read())
               {
                 string Sql = "insert into tblClientInfo(ClientId,Name) values(" + dr.GetInt32(0).ToString() + "," + dr.GetString(1) + ")";

               SqlCommand cmd1 = new SqlCommand (Sql,dbcon2);


[edit]Code block added[/edit]
Posted
Updated 26-Jul-13 3:01am
v2
Comments
Sajith Dilhan 26-Jul-13 9:01am    
you can sync data with some tools like Redgate data compare

http://www.red-gate.com/products/sql-development/sql-data-compare/
ZurdoDev 26-Jul-13 9:10am    
You want to do it when the server is offline? You'll have to dump the data somewhere until the server comes back online.
Asp_Learner 26-Jul-13 10:43am    
How you can do if server is offline? Please make clear about offline
sadhana4 29-Jul-13 1:49am    
I have configureg my application in local intranet. so there i need some client requirement to move some secure data from local db to production daily..

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