code for Form1.cs:
using System;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace Insert_Data
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection conn=new SqlConnection("Data Source=ZAKIHP-PC\\ZAKISQL;Initial Catalog=LICT_DotnetDB;Integrated Security=True");
conn.Open();
SqlCommand sc=new SqlCommand("insert into Emp values('"+textBox1.Text+ "','" + textBox2.Text + "','" + textBox3.Text + "','"+textBox4.Text+"','" + textBox5.Text + "');",conn);
int o = sc.ExecuteNonQuery();
MessageBox.Show(o + ": Record has been inserted");
conn.Close();
}
public static void main(string[] args)
{
Application.Run(new Form1());
}
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
There is also Form1.cs design