I keep getting this annoying error. I really new to SQL and this literally my first query ever and I just cannot get it to work. I have been trying for hours. Please help!
I get the error:
System.Data.SqlClient.SqlException: 'Must declare the scalar variable "@FirstNamez".
Code:
public static void CreateNewEmployee(string FirstNamez, string LastNamez, int Pinz, string Departmentz)
{
SqlConnection connection = new SqlConnection();
connection.ConnectionString = @"Server = localhost\SQLEXPRESS; Database = Employee; Trusted_Connection = True;";
SqlCommand command = new SqlCommand();
using (connection)
{
connection.Open();
string commandtext = "INSERT INTO dbo.EmployeeDatabase (FirstName, LastName, PIN, Department) VALUES (@FirstNamez, @Lastnamez, @Pinz, @Departmentz);";
command.CommandText = commandtext;
command.Connection = connection;
command.ExecuteNonQuery();
}
}