You use two separate connection objects:
SqlConnection con1 = new SqlConnection(@"Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\sms.mdf;Integrated
Security=True;Connect Timeout=30;User Instance=True");
SqlConnection con2 = new SqlConnection(@"Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\sms2.mdf;Integrated
Security=True;Connect Timeout=30;User Instance=True");
solved How To Access Two Databases in a Single connection String in C#?