これを実行しようとすると、次のエラー メッセージが表示されます。
varchar 値 'category_id' をデータ型 int に変換するときに変換に失敗しました。
これが私のSQLとパラメータコードです。うまくいくはずですが、うまくいきません。
mycmd.CommandText="SELECT * FROM categories WHERE @db_property = @property_id";
// This contains a string "category_id", which is correct.
mycmd.Parameters.Add("@db_property", SqlDbType.VarChar).Value=db_property_field;
// This contains an Int, referring to the category_id in database. As of now, this is 1
mycmd.Parameters.Add("@property_id", SqlDbType.Int).Value=property_id;
このコードを実行した後、Reader で実行すると、上記のエラー メッセージが表示されます。先生や私のクラスの優秀な生徒たちに尋ねてきましたが、問題がどこにあるのか、誰も手がかりを見つけることができません.