当我尝试运行程序时,我收到此错误,我无法解决它。是因为我试图从同一方法获取数据。
rivate void populateTableTopping()
{
string query = "SELECT a.Name FROM Toppings a " +
"INNER JOIN Table b ON a.Id = b.ToppingsId " +
"WHERE b.TypeId = @TypeId";
using (Connection = new SqlConnection(connectionstring))
using (SqlCommand command = new SqlCommand(query, Connection))
using (SqlDataAdapter adapter = new SqlDataAdapter(command))
{
command.Parameters.AddWithValue("@TypeId", sizeTypeListBox.SelectedValue);
DataTable tableToppingTable = new DataTable();
adapter.Fill(tableToppingTable);
tableToppingListBox.DisplayMember = "Name";
tableToppingListBox.ValueMember = "Id";
tableToppingListBox.DataSource = tableToppingTable;
}
}
并在Adapter.fill中收到此错误: System.ArgumentException:'从对象类型System.Data.DataRowView到已知的托管提供程序本机类型不存在映射。'