Click here to Skip to main content
15,903,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I need a help on the below situation,please..

I am working with ASP.net C# application which is connected to sql 2008 R2 with a DB say myTestDB. My application is inserting ,updating and deleting on the tables in this DB.

Now I need to implement a logic in which on certain conditions, the data will get saved to a table in another DB -say mySecondDB


I came to know that we can either handle different connection string in the web.confing to the "mysecondDB" and connect

or i can handle in the back end (SQL) by insert inti mysecondDb.dbo.tablename

I don't know any other option we can use.

Please advise the optimum and fast method for doing this.

Thanks in advance..
Posted

1 solution

Solution 1:

Do not use database.owner.object in your procedures, use only owner.object and let the connection to select the database. Then you can easily change SqlConnection before calling the procedure.

Solution 2:

If you like to have a copy of your database use a replica, and set the replication rules in the database server.
 
Share this answer
 
Comments
Member 10112611 19-Mar-15 6:42am    
you mean to define the connection string in c#code ? Not replica.. I have to save some data to another DB based on the interface selection
Joan Magnet 19-Mar-15 6:47am    
Yes, you can have two or more connections and use one of them depending on some conditions. Same procedures, different database.

Our intranet works this way.
Member 10112611 19-Mar-15 6:51am    
Thanks a lot...mine is web application.. I am worried about the perfomance. hope it will be faster compared to using database.owner.object in your procedures ...

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