Skip to content

How to connect multiple access databases in asp.net?

Prabhakar Reddy

Asked Aug 26, 2012, 8:32 PM EDT2 answers
Share
LinkedInX
Hi,
Good Morning,

I have a reqiurement,
i,e i need to connect multiple access databases with a single common field, in asp.net, how to connect and the steps please tell to me..
Thanks 

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Java
    SqlConnection con1 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["con1"].ConnectionString);
        SqlConnection con2 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["con2"].ConnectionString);
    
        SqlCommand cmd = new SqlCommand("select * from table1", con1);
        SqlDataReader dr;
        con1.Open();
        dr = cmd.ExecuteReader(CommandBehavior.SingleResult);
        while (dr.Read())
        { 
      //  ....
        }dr.Close()
    
       //your condition then fire insert commnd with connection con2 
    
        SqlCommand insertcmd = new SqlCommand("insert into table2", con2);
        SqlDataAdapter dap = new SqlDataAdapter(insertcmd);
    0
  • Akkiraju Ivaturi
    0
    Configure two connection strings in web.config and always make sure that you close one connection before using another.

    Command object should be general for any connection. Which ever connection you would like to use, set the connection for the Command object to that particular connection.
    0