さまざまなパラメーターを持つオブジェクトを介して SQL に送信していますが、成功または失敗を示すために 0 または 1 の値を受け取る必要があります。
すべてのパラメーターが正常に SQL に送信されることを確認しましたが、C# に返す必要がある "@Result" 値に関して問題が発生しています。
以下は、Data.cs ファイル内のコードの抜粋です。
public System.Data.DataSet spe_ISUpgradePossible(dbObject currentDBObj)
{
using (System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(ConnectionString))
{
using (System.Data.SqlClient.SqlCommand command = GetCommand("spe_ISUpgradePossible", connection))
{
command.CommandType = System.Data.CommandType.StoredProcedure;
System.Data.SqlClient.SqlParameter parameter;
parameter = new System.Data.SqlClient.SqlParameter("@ServicePack", System.Data.SqlDbType.NVarChar);
parameter.Direction = System.Data.ParameterDirection.Input;
parameter.Value = currentDBObj.servicePack;
command.Parameters.Add(parameter);
parameter = new System.Data.SqlClient.SqlParameter("@ServicePackFolder", System.Data.SqlDbType.NVarChar);
parameter.Direction = System.Data.ParameterDirection.Input;
parameter.Value = currentDBObj.servicePackFolder;
command.Parameters.Add(parameter);
parameter = new System.Data.SqlClient.SqlParameter("@Result", System.Data.SqlDbType.Int);
parameter.Direction = System.Data.ParameterDirection.Output;
command.Parameters.Add(parameter);
System.Data.DataSet dataSet = new System.Data.DataSet();
System.Data.SqlClient.SqlDataAdapter adapter = new System.Data.SqlClient.SqlDataAdapter(command);
adapter.Fill(dataSet);
return dataSet;
//int result = Convert.ToInt16(command.Parameters["@Result"].Value.ToString());
//return result;
}
}
}
「@Result」に対応するために、次の 2 行を追加しました。
//int result = Convert.ToInt16(command.Parameters["@Result"].Value.ToString());
//return result;
これにより、次のエラーが表示されました: 「タイプ 'int' を 'System.Data.Dataset' に暗黙的に変換できません」
上記の問題を回避する方法を教えてください。任意の支援をいただければ幸いです。