using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
namespace ConsoleApp58
{
class Program
{
static void Main(string[] args)
{
string con = "Data Source=JAGADEESH\\SQLEXPRESS;Initial Catalog=Jagadeesh;User ID=sa;Password=9030302074";
string qry = "insert into Employee2(eno,firstname,lastname,age,disg,doj,sal) values(@eno,@firstname,@lastname,@age,@disg,@doj,@sal)";
using (SqlConnection conn1 = new SqlConnection(con))
{
try
{
conn1.Open();
SqlCommand cmd = new SqlCommand(qry, conn1);
Console.WriteLine("enter eno");
cmd.Parameters.AddWithValue("@eno",System.Console.ReadLine());
Console.WriteLine("enter First name");
cmd.Parameters.AddWithValue("@firstname", System.Console.ReadLine());
Console.WriteLine("enter lastname ");
cmd.Parameters.AddWithValue("@lastname", System.Console.ReadLine());
Console.WriteLine("enter age");
cmd.Parameters.AddWithValue("@age",Convert.ToInt32(Console.ReadLine()));
Console.WriteLine("enter disg");
cmd.Parameters.AddWithValue("@disg", System.Console.ReadLine());
Console.WriteLine("enter doj");
cmd.Parameters.AddWithValue("@doj", Convert.ToDateTime(System.Console.ReadLine()));
Console.WriteLine("enter sal");
cmd.Parameters.AddWithValue("@sal",Convert.ToDecimal(System.Console.ReadLine()));
cmd.ExecuteNonQuery();
Console.WriteLine("Insert data");
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.ReadKey();
}
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
namespace ConsoleApp58
{
class Program
{
static void Main(string[] args)
{
string con = "Data Source=JAGADEESH\\SQLEXPRESS;Initial Catalog=Jagadeesh;User ID=sa;Password=9030302074";
string qry = "insert into Employee2(eno,firstname,lastname,age,disg,doj,sal) values(@eno,@firstname,@lastname,@age,@disg,@doj,@sal)";
using (SqlConnection conn1 = new SqlConnection(con))
{
try
{
conn1.Open();
SqlCommand cmd = new SqlCommand(qry, conn1);
Console.WriteLine("enter eno");
cmd.Parameters.AddWithValue("@eno",System.Console.ReadLine());
Console.WriteLine("enter First name");
cmd.Parameters.AddWithValue("@firstname", System.Console.ReadLine());
Console.WriteLine("enter lastname ");
cmd.Parameters.AddWithValue("@lastname", System.Console.ReadLine());
Console.WriteLine("enter age");
cmd.Parameters.AddWithValue("@age",Convert.ToInt32(Console.ReadLine()));
Console.WriteLine("enter disg");
cmd.Parameters.AddWithValue("@disg", System.Console.ReadLine());
Console.WriteLine("enter doj");
cmd.Parameters.AddWithValue("@doj", Convert.ToDateTime(System.Console.ReadLine()));
Console.WriteLine("enter sal");
cmd.Parameters.AddWithValue("@sal",Convert.ToDecimal(System.Console.ReadLine()));
cmd.ExecuteNonQuery();
Console.WriteLine("Insert data");
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.ReadKey();
}
}
}
}
No comments:
Post a Comment