-
Notifications
You must be signed in to change notification settings - Fork 1
/
RegisterPage.xaml.cs
55 lines (47 loc) · 1.49 KB
/
RegisterPage.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
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.Navigation;
using System.Windows.Shapes;
namespace IoT1
{
/// <summary>
/// Interaction logic for RegisterPage.xaml
/// </summary>
public partial class RegisterPage : Page
{
public RegisterPage()
{
InitializeComponent();
}
SqlConnection conn = new SqlConnection(@"Data Source=(localdb)\Local;Initial Catalog=LoginDB;Integrated Security=True");
private void Button_Click(object sender, RoutedEventArgs e)
{
try
{
SqlCommand cmd = new SqlCommand("INSERT INTO tblUser VALUES (@Username, @Password)", conn);
cmd.CommandType = System.Data.CommandType.Text;
cmd.Parameters.AddWithValue("@Username", txt_Username.Text);
cmd.Parameters.AddWithValue("@Password", txt_Password.Password);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
MessageBox.Show("Registration Completed ");
}
catch (SqlException Ex)
{
MessageBox.Show(Ex.Message);
}
}
}
}