using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace Attendance
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void SignButton_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=(localdb)\\Projects;Initial Catalog=MyDatabase;Integrated Security=True;");
con.Open();
SqlCommand cmd = new SqlCommand("INSERT INTO User(Username,Password,Firstname,MiddleInitial,Lastname,Age,Phone,Address,City,State,Email) VALUES(@user,@pass,@first,@middle,@last,@age,@phone,@add,@city,@state,@email)",con);
cmd.Parameters.AddWithValue("@user",UsernameTB.Text);
cmd.Parameters.AddWithValue("@pass",PasswordTB.Text);
cmd.Parameters.AddWithValue("@first",FirstnameTB.Text);
cmd.Parameters.AddWithValue("@middle",MiddleTB.Text);
cmd.Parameters.AddWithValue("@last",LastnameTB.Text);
cmd.Parameters.AddWithValue("@age",AgeTB.Text);
cmd.Parameters.AddWithValue("@phone",PhoneTB.Text);
cmd.Parameters.AddWithValue("@add",AddressTB.Text);
cmd.Parameters.AddWithValue("@city",CityTB.Text);
cmd.Parameters.AddWithValue("@state",StateTB.Text);
cmd.Parameters.AddWithValue("@email",EmailTB.Text);
cmd.ExecuteNonQuery();
MessageBox.Show("Record has been inserted");
con.Close();
}
}
}