0

DB(Oracle、SQLサーバー)に関係なく同じコードを使用できるように、DBに依存しないメソッドを作成しようとしています。

これにはIDbConnectionおよびIDbCommandインターフェイスを使用しています。プロシージャを呼び出しているときに、Illegal Variable name /numbererrorというエラーが表示されます。インラインクエリを直接呼び出すことはできますが(コマンドテキストとしてクエリを直接指定します)これがサンプル呼び出しです。

using (IDbConnection connection = this._providerFactory.CreateConnection())
                {
                    // create the command object using the conneciton object
                    IDbCommand command = connection.CreateCommand();
                    //start
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "GetResponse";

                   IDbDataParameter menuParam = this._providerFactory.CreateParameter();
                   menuParam.DbType = DbType.String;
                   menuParam.Direction = ParameterDirection.Input;
                   menuParam.ParameterName = "@V_USER_ID";
                   command.Parameters.Add(menuParam);

                   IDbDataParameter menuParam2 = this._providerFactory.CreateParameter();
                   menuParam2.Size = 20;

                   menuParam2.DbType = DbType.String;
                   menuParam2.Size = 20;
                   menuParam2.Direction = ParameterDirection.Output;
                   menuParam2.ParameterName = "@V_ROLE_ID";
                   menuParam2.Value = DBNull.Value;
                   command.Parameters.Add(menuParam2);
                    //end



                    command.ExecuteNonQuery();

}
4

1 に答える 1

0

ここには値が指定されていません (@ 記号を削除します):

             IDbDataParameter menuParam = this._providerFactory.CreateParameter(); 
               menuParam.DbType = DbType.String; 
               menuParam.Direction = ParameterDirection.Input; 
               menuParam.ParameterName = "V_USER_ID"; 
               command.Parameters.Add(menuParam); 
于 2012-07-15T15:59:21.327 に答える