Beispiel #1
0
 public void addEmployes(Employes emp)
 {
     try
     {
         ConnectionString connect = new ConnectionString();
         using (SqlConnection con = new SqlConnection(connect.connect))
         {
             con.Open();
             using (SqlCommand com = new SqlCommand("insert into [Employes]([name], [salary], [experience]) values(@name, @salary, @experience)", con))
             {
                 com.Parameters.AddWithValue("@name", emp.name);
                 com.Parameters.AddWithValue("@salary", emp.salary);
                 com.Parameters.AddWithValue("@experience", emp.experience);
                 com.ExecuteNonQuery();
             }
         }
         Console.WriteLine("Пользователь успешно добавлен.");
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }