using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; using System.Data.SqlClient; using System.IO; namespace Practics { /// /// Interaction logic for DBRegistrationWindow.xaml /// public partial class DBRegistrationWindow : Window { //string connectionString = "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=dbtechsphere;Integrated Security=True;Connect Timeout=30;Encrypt=False"; //string currentDirectory = Directory.GetCurrentDirectory(); //AttachDbFilename=C:\\Path\\To\\Database\\dbtechsphere.mdf public DBRegistrationWindow() { InitializeComponent(); } private void btnDBConnect_Click(object sender, RoutedEventArgs e) { // string connectionString = "Data Source=(localdb)\\MSSQLLocalDB;AttachDbFilename="+currentDirectory+"\\dbtechsphere.mdf;Integrated Security=True;Connect Timeout=30;Encrypt=False"; SqlConnection conn = new SqlConnection(Model.Model.connectionString); conn.Open(); conn.Close(); } } }