please I'm trying to insert values from a textbox into the database. but I'm having this error when debugging
" No mapping exists from object type System.Windows.Forms.TextBox to a managed provider native type." please help this is my code for the connection
private void SaveBtn1_Click(object sender, EventArgs e)
{
try
{
string connectionString = @"Data Source=JEREMIAH-HP\SQLEXPRESS;Initial Catalog=CgpaCalculator;Integrated Security=True";
SqlConnection sqlCon = new SqlConnection(connectionString);
sqlCon.Open();
using (SqlConnection connection = new SqlConnection(connectionString))
using (SqlCommand command = connection.CreateCommand())
{
command.CommandText = "INSERT INTO StudInfo(Matric_ID, First_Name, Last_Name, Dept,Level,Cgpa,Entry mode) VALUES (@Matric_ID, @ First_Name, @ Last_Name, @Dept, @Level, @Cgpa, @Entry mode)";
command.Parameters.AddWithValue("@ Matric_ID",matricNo);
command.Parameters.AddWithValue("@First_Name",frstName);
command.Parameters.AddWithValue("@Last_Name", lstName);
command.Parameters.AddWithValue("@Dept",department );
command.Parameters.AddWithValue("@Level",Level );
command.Parameters.AddWithValue("@Cgpa",cgpa);
command.Parameters.AddWithValue("@Entry mode",mdeofentry);
connection.Open();
command.ExecuteNonQuery();
}
}
catch (SqlException ex)
{
MessageBox.Show("There is an Error in saving file" + ex);
}
}