OracleLob SQL Server varbinary等效对象,用于读取VarBinary(max)C#

时间:2018-09-27 08:03:51

标签: c# sql sql-server database

我们最近从oracle迁移到了ms sql server,但我无法从SQL Server读取VarBinary(max)

oracle的代码是

    private byte[] CallSelectBlob(string aSqlCommand)
    {
        byte[] result = new byte[0];
        OracleCommand comm = new OracleCommand(aSqlCommand, oc);
        OracleDataReader reader = comm.ExecuteReader(System.Data.CommandBehavior.Default);

        while (reader.Read())
        {
            for (int i = 0; i < reader.FieldCount; i++)
            {
                string fieldName = reader.GetName(i);
                OracleLob myLob = reader.GetOracleLob(i);
                if (!myLob.IsNull)
                {
                    byte[] b = new byte[myLob.Length];
                    myLob.Read(b, 0, Convert.ToInt32(myLob.Length));
                    result = b;
                }
            }
        }
        reader.Close();
        return result;
    }

那很好,但是我无法找到可以将OracleLob替换为VarBinary(max)(将作为pdf文件)的对象的对象

该函数应将其作为字节[]返回。

有人知道一种可以实现这一目标的方法吗?

0 个答案:

没有答案
相关问题