本文整理汇总了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
}