DBRegistrationWindow.xaml.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Shapes;
  14. using System.Data.SqlClient;
  15. using System.IO;
  16. namespace Practics
  17. {
  18. /// <summary>
  19. /// Interaction logic for DBRegistrationWindow.xaml
  20. /// </summary>
  21. public partial class DBRegistrationWindow : Window
  22. {
  23. //string connectionString = "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=dbtechsphere;Integrated Security=True;Connect Timeout=30;Encrypt=False";
  24. //string currentDirectory = Directory.GetCurrentDirectory();
  25. //AttachDbFilename=C:\\Path\\To\\Database\\dbtechsphere.mdf
  26. public DBRegistrationWindow()
  27. {
  28. InitializeComponent();
  29. }
  30. private void btnDBConnect_Click(object sender, RoutedEventArgs e)
  31. {
  32. // string connectionString = "Data Source=(localdb)\\MSSQLLocalDB;AttachDbFilename="+currentDirectory+"\\dbtechsphere.mdf;Integrated Security=True;Connect Timeout=30;Encrypt=False";
  33. SqlConnection conn = new SqlConnection(Model.Model.connectionString);
  34. conn.Open();
  35. conn.Close();
  36. }
  37. }
  38. }