Im trying to make CRUD aplication in .net Framework, where I can insert/edit/delete employee in SQL Server. When i try to insert new employee it gaves me error : "System.Data.SqlClient.SqlException: 'Invalid object name 'dbo.GestAttivita'.' " in controller.
This is my controller :
using static DataLibrary.Logic.ProcessoreTecnico;           
            [HttpPost]
            [ValidateAntiForgeryToken]
            public ActionResult SignUp(TecniciModel tecniciModel)
            {
                if (ModelState.IsValid)
                {
                    int recordsCreated = CreareTecnico(tecniciModel.Id,
                        tecniciModel.Nome,
                        tecniciModel.Cognome,
                        tecniciModel.Cellulare);
                    return RedirectToAction("Index");
                }
                return View();
            }
SqlException (0x80131904): Invalid object name 'GestAttivita'
And this is the class ProcessoreTecnico :
public static class ProcessoreTecnico
    {
        public static int CreareTecnico(int id, string nome, string cognome, 
             string cellulare)
        {
            TecniciModel data = new TecniciModel
            {
                Id = id,
                Nome = nome,
                Cognome = cognome,
                Cellulare = cellulare
            };
            string sql = @"insert into dbo.GestAttivita(id, nome, cognome,  cellulare)
                            values (@Id, @Nome, @Cognome, @Cellulare);";
            return SqlDataAccess.SaveData(sql, data);
        }
        public static List<TecniciModel> CaricaTecnici()
        {
            string sql = @"select id, nome, cognome, cellulare
                            from dbo.GestAttivita;";
            return SqlDataAccess.LoadData<TecniciModel>(sql);
        }
    }
I can't get it gives me that error. Any ideas how to fix this? Thanks in advance!
User contributions licensed under CC BY-SA 3.0