What will be the best practices in my code to prevent sql injection?

What will be the best practices to prevent sql injection? My client asked me to prevent sql injection. I used this structure for data inserting or updating public bool Add(GreenItem aGreenItem, Employee emp) { aGreenItem.GreenItemCode = new CommonBLL().GetMaxId("[GreenItemCode]", "[Processing].[GreenItem]", "GTM"); using (SqlConnection objConnection = Connection.GetConnection()) { SqlTransaction transaction = objConnection.BeginTransaction("SampleTransaction"); try { string query = … Read more

SQL Network Interfaces, error: 50 – Local Database Runtime error occurred. Cannot create an automatic instance

I am trying to build an ASP.NET MVC 5 Web Application which has a MyDatabase.mdf file in the App_Data folder. I have SQL Server 2014 Express installed with a LocalDb instance. I can edit the database tables using the Server Explorer, however when I debug the application and go to a page where the database is needed I get the following error.