0

im just new in ASP.net using MVC and my problem is im using two database, is there any posibility that i can use to get data of 1 st database and transfer it to another database? any help will be appreciated , even links

zero
  • 21
  • 3
  • Is both databases are being accessed from dame application? – Adersh M Aug 04 '16 at 06:41
  • Use proper `tags` . This Question is not related to `javascript`,`json`,`ajax`.. – mmushtaq Aug 04 '16 at 06:56
  • @AdershM yes, im using both database in my application. my agenda is to create a user access where the data will be provided on the first database then will be saved in my 2nd database , the module need is when user starting to create User account once he/she enter the specific ID the fields will be auto complete from the data from the first database then once done will be saved in my second database, please help ? any will do thanks. i just newbie – zero Aug 04 '16 at 06:59
  • noted @user55. thanks – zero Aug 04 '16 at 07:03
  • you could try with ADO.NET as said by @mahlatse, its easy to manage multiple connection strings in POCO classes rather than in EF db context.. – Adersh M Aug 04 '16 at 07:39

2 Answers2

0

1) Using Entity Framework, create 2 classes that implement DBContext and use them to update the data.

2) Use Linq To Sql to create access the Databases and save your detail.

3)Just use simple ADO.NET to save the data.ps. change your connections string to match your required databases.

mahlatse
  • 1,322
  • 12
  • 24
0

Try this below, using ADO.NET

    using (SqlConnection connection = new SqlConnection("Integrated Security=SSPI;Initial Catalog=DB1"))
    {
        connection.Open(); 
        // here you could read the data from DB1
    }

    using (SqlConnection connection = new SqlConnection("Integrated Security=SSPI;Initial Catalog=DB2"))
    {
        connection.Open();      
        // Write data to DB2 here
    }
Adersh M
  • 596
  • 3
  • 19
  • @AderchM hello i see what your just saying and thanks for the tip, is there wont any problem? regarding IEnumerable? because on the view only one will work right? – zero Aug 04 '16 at 07:58
  • Do this in a separate file, like for e.g. DataMapper.cs, which is used only for db operations. link this file to your controller using an interface. And using this,you don't need to worry about your view. – Adersh M Aug 04 '16 at 08:31
  • also, have a look at this post http://stackoverflow.com/questions/11064316/what-is-viewmodel-in-mvc?noredirect=1&lq=1 – Adersh M Aug 04 '16 at 08:35
  • thanks men, your a hero will follow you tip. thanks once again – zero Aug 04 '16 at 08:46
  • No problem...pls let me know if you stuck somwhere – Adersh M Aug 04 '16 at 09:31
  • hello @ Adersh M can i get your email so i can ask you personally on the question i had? if you don mind , thanks once again – zero Aug 05 '16 at 02:49