When executing command.Prepare() I have “SqlCommand.Prepare method requires all parameters to have an explicitly set type” error
I have the following statements: SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["DataBaseName"]); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "update Table1 set data = @data where id = @id"; cmd.Parameters.AddWithValue("@data", SqlDbType.VarChar).Value = data; cmd.Parameters.AddWithValue("@id", SqlDbType.Int).Value = id; cmd.CommandType = CommandType.Text; try { DataSet ds = new DataSet(); con.Open(); cmd.Prepare(); cmd.ExecuteNonQuery(); return true; } When executing cmd.Prepare() I have an error SqlCommand.Prepare method requires all