当前位置: 首页>>代码示例>>C#>>正文


C# SqlDataRecord.SetSqlBinary方法代码示例

本文整理汇总了C#中Microsoft.SqlServer.Server.SqlDataRecord.SetSqlBinary方法的典型用法代码示例。如果您正苦于以下问题:C# SqlDataRecord.SetSqlBinary方法的具体用法?C# SqlDataRecord.SetSqlBinary怎么用?C# SqlDataRecord.SetSqlBinary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.SqlServer.Server.SqlDataRecord的用法示例。


在下文中一共展示了SqlDataRecord.SetSqlBinary方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SPGetBoxCutout


//.........这里部分代码省略.........
            dataList.Clear();

            SqlCommand createTempTable = new SqlCommand(
                "create table #tempdata ( offsets varbinary(8000), data varbinary(8000))", connection);
            createTempTable.ExecuteNonQuery();

            foreach (Tuple<int[], byte[]> data2Tuple in dataList2)
            {
                SqlIntArray offsets = new SqlIntArray(4);
                offsets[0] = 0;
                offsets[1] = data2Tuple.Item1[0];
                offsets[2]= data2Tuple.Item1[1];
                offsets[3] = data2Tuple.Item1[2];

                SqlCommand insertCommand = new SqlCommand("insert into #tempdata (offset, data) values (@offest, @blob)", connection);
                insertCommand.Parameters.Add("@offest", SqlDbType.VarBinary, 8000).Value = offsets.ToSqlBuffer();
                insertCommand.Parameters.Add("@blob", SqlDbType.VarBinary, 8000).Value = data2Tuple.Item2;
                insertCommand.ExecuteNonQuery();
            }

            SqlIntArray lengths = new SqlIntArray(4);
            lengths[0] = 3;
            lengths[1] = bx-ax;
            lengths[2] = by-ay;
            lengths[3] = bz-az;

            string concatBlobsQuery = "select * from RealArray.FromSubarrayTable('#tempdata', @lengths)";
            SqlCommand concatBlobCommand = new SqlCommand(concatBlobsQuery, connection);
            concatBlobCommand.Parameters.Add("@lengths", SqlDbType.VarBinary, 8000).Value = lengths.ToSqlBuffer();
            //SqlCommand concatBlobs = new

            SqlDataReader concatBlobReader = concatBlobCommand.ExecuteReader();
            // what should be the return type? of type data?
            SqlDataRecord record = new SqlDataRecord(new SqlMetaData("data", SqlDbType.VarBinary, -1));
            try
            {
                while (concatBlobReader.Read())
                {
                    //concatBlobReader[0];
                    record.SetSqlBinary(0, concatBlobReader.GetSqlBinary(0).Value);
                    SqlContext.Pipe.Send(record);
                }
            }
            finally
            {
                // Always call Close when done reading.
                concatBlobReader.Close();
            }

            /*

            Int16[] lengths = new Int16[dataList.Count];
            SqlCommand createTempTable = new SqlCommand(
                "create table #tempdata ( offsets varbinary(8000), data varbinary(8000))", connection);
            createTempTable.ExecuteNonQuery();
            int index = 0;

            foreach (byte[] atoms in dataList)
            {
                SqlCommand insertCommand = new SqlCommand("insert into #tempdata (offset, data) values (@offest, @blob)", connection);
                insertCommand.Parameters.Add("@offest", SqlDbType.VarBinary, 8000).Value = offsets;
                insertCommand.Parameters.Add("@blob", SqlDbType.VarBinary, 8000).Value = atoms;
                insertCommand.ExecuteNonQuery();
                lengths[index] = (Int16)dataList[index].Length;
                index++;
            }

            SqlIntArray lengthsArray = new SqlIntArray(lengths);
            SqlBinary lengthsBlob = lengthsArray.ToSqlBuffer();
            string concatBlobsQuery = "select * from RealArray.FromSubarrayTable('#tempdata', @lengths)";
            SqlCommand concatBlobCommand = new SqlCommand(concatBlobsQuery, connection);
            concatBlobCommand.Parameters.Add("@lengths", SqlDbType.VarBinary, 8000).Value = lengthsBlob;
            //SqlCommand concatBlobs = new

            SqlDataReader concatBlobReader = concatBlobCommand.ExecuteReader();
            // what should be the return type? of type data?
            SqlDataRecord record = new SqlDataRecord(new SqlMetaData("data", SqlDbType.VarBinary, -1));
            try
            {
                while (concatBlobReader.Read())
                {
                    //concatBlobReader[0];
                    record.SetSqlBinary(0, concatBlobReader.GetSqlBinary(0).Value);
                    SqlContext.Pipe.Send(record);
                }
            }
            finally
            {
                // Always call Close when done reading.
                concatBlobReader.Close();
            }

            */

        }

        //grab set of indices to look at
        //get data from each matched index
        //concatenate returned data
    }
开发者ID:madmaze,项目名称:SpartialBoxExtracter,代码行数:101,代码来源:SPGetBoxCutout.cs


注:本文中的Microsoft.SqlServer.Server.SqlDataRecord.SetSqlBinary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。