Step 1 :
Step 2 :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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;
using System.Data.SqlClient;
namespace WpfApplication2
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
string cs = "server=NAGABABU-PC;database=nagababu;uid=sa;pwd=abc";
public MainWindow()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
SqlConnection con = new SqlConnection(cs);
int eno = Convert.ToInt32(textBox1.Text);
string ename = textBox2.Text;
double sal = double.Parse(textBox3.Text);
SqlCommand cmd = new SqlCommand("insert into emp values (@eno,@ename,@sal)", con);
cmd.Parameters.AddWithValue("@eno", eno);
cmd.Parameters.AddWithValue("@ename", ename);
cmd.Parameters.AddWithValue("@sal", sal);
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
if (i == 1)
{
label4.Content = "Record Inserted Successfully";
}
else
{
label4.Content = "Record Not Inserted";
}
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
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;
using System.Data.SqlClient;
namespace WpfApplication2
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
string cs = "server=NAGABABU-PC;database=nagababu;uid=sa;pwd=abc";
public MainWindow()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
SqlConnection con = new SqlConnection(cs);
int eno = Convert.ToInt32(textBox1.Text);
string ename = textBox2.Text;
double sal = double.Parse(textBox3.Text);
SqlCommand cmd = new SqlCommand("insert into emp values (@eno,@ename,@sal)", con);
cmd.Parameters.AddWithValue("@eno", eno);
cmd.Parameters.AddWithValue("@ename", ename);
cmd.Parameters.AddWithValue("@sal", sal);
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
if (i == 1)
{
label4.Content = "Record Inserted Successfully";
}
else
{
label4.Content = "Record Not Inserted";
}
}
}
}