mysqlデータベースファイルからIDが2,4,6のレコードの配列を選択したいとします。私は整数の配列をMySQLのストアプロシージャに渡そうとしています。しかし、私は働くストアドプロシージャを作成することに失敗します。MySql select ...にパラメータの配列を渡す方法
1つを構成するのに役立ちますか?
これは、これがMySQLの
あるC#コード
public static List<PhotoComment> GetPhotos(int[] _ids)
{
MySqlConnection _con = Generals.GetConnnection();
List<PhotoComment> _comments = new List<PhotoComment>();
try
{
MySqlCommand _cmd = new MySqlCommand("Photos_GetPhotosByIDs", _con);
_cmd.CommandType = CommandType.StoredProcedure;
_cmd.Parameters.AddWithValue("@_ids", _ids);
_con.Open();
MySqlDataReader _reader = _cmd.ExecuteReader();
while (_reader.Read())
{
PhotoComment _comment = new PhotoComment(_reader.GetInt32("cID"), _reader.GetInt32("cFID"), _reader.GetString("cUser"), _reader.GetString("cContent"), _reader.GetDateTime("cDate"), _reader.GetBoolean("cChecked"));
_comments.Add(_comment);
}
_con.Close();
}
catch (Exception _ex)
{
_con.Close();
ReportMgr.ReportException(_ex.Message);
}
return _comments;
}
ある= root
localhost
@ PROCEDURE Photos_GetPhotosByIDs
をDEFINERをCREATEは(_idsの[] INT)
が
*が選択BEGIN tbl_photosから_id内のID。
終了
私たちとコードを共有することはできますか? –